WebSocketServer.clientsByCamera

This commit is contained in:
2026-07-04 18:09:16 +05:00
parent e0437edf18
commit eb001771b5
4 changed files with 29 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
import { log } from '../helpers/log.js'
import { lastTopicSegment } from '../helpers/topic-match.js'
import { onEdgeChunk } from '../stream/edge-chunk-relay.js'
import type { TopicHandler } from '../types.js'
const LOG_INTERVAL_MS = 10_000
@@ -9,15 +10,12 @@ const lastLogByCamera = new Map<string, number>()
export const handleEdge5VideoV2: TopicHandler = async (topic, payload) => {
const cameraId = lastTopicSegment(topic)
if (!cameraId) {
console.warn('edge5.video.v2.invalid_topic', { topic })
return
}
const now = Date.now()
const lastLog = lastLogByCamera.get(cameraId) ?? 0
if (now - lastLog >= LOG_INTERVAL_MS) {
log(`edge5.video.v2 [${cameraId}] ↑ ${payload.length}B`)
lastLogByCamera.set(cameraId, now)
}
onEdgeChunk(cameraId, payload);
}

View File

@@ -11,5 +11,5 @@ export const handleEdge5Video: TopicHandler = async (_topic, payload) => {
log(`edge5.video ↑ ${payload.length}B`)
lastLog = now
}
onEdgeChunk(payload)
onEdgeChunk('v1', payload);
}