From 355621032a1e0ccdfaa5e9a3616119ceb7d5e6ca Mon Sep 17 00:00:00 2001 From: Nicolai Ommer Date: Sun, 25 Apr 2021 18:54:20 +0200 Subject: [PATCH] Remove vanished tracking sources --- pkg/tracked/receiver.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/tracked/receiver.go b/pkg/tracked/receiver.go index 9ecfa01..ba5c448 100644 --- a/pkg/tracked/receiver.go +++ b/pkg/tracked/receiver.go @@ -33,6 +33,7 @@ func (r *Receiver) TrackedFrames() map[string]*TrackerWrapperPacket { r.mutex.Lock() defer r.mutex.Unlock() + r.cleanupOldSources() frames := map[string]*TrackerWrapperPacket{} for k, v := range r.frames { frames[k] = v @@ -61,11 +62,11 @@ func parseVisionWrapperPacket(data []byte) (message *TrackerWrapperPacket, err e return } -func (r *Receiver) cleanupDetections() { - for camId, t := range r.receivedTimes { +func (r *Receiver) cleanupOldSources() { + for uuid, t := range r.receivedTimes { if time.Now().Sub(t) > time.Second { - delete(r.receivedTimes, camId) - delete(r.frames, camId) + delete(r.receivedTimes, uuid) + delete(r.frames, uuid) } } }