WebSocketServer.clientsByCamera
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ export const handleEdge5Video: TopicHandler = async (_topic, payload) => {
|
||||
log(`edge5.video ↑ ${payload.length}B`)
|
||||
lastLog = now
|
||||
}
|
||||
onEdgeChunk(payload)
|
||||
onEdgeChunk('v1', payload);
|
||||
}
|
||||
Reference in New Issue
Block a user