diff --git a/frontend/ts/batch-timer.ts b/frontend/ts/batch-timer.ts index ab5f735..e0e02c9 100644 --- a/frontend/ts/batch-timer.ts +++ b/frontend/ts/batch-timer.ts @@ -10,9 +10,11 @@ export class BatchTimer { } public queue(id: string, timeout: number){ - this._timer = new Date().getTime() + timeout; - this._batch.push(id); - setTimeout(this.checkBatch.bind(this), timeout); + if (!this._batch.includes(id)) { + this._timer = new Date().getTime() + timeout; + this._batch.push(id); + setTimeout(this.checkBatch.bind(this), timeout); + } } private checkBatch() { diff --git a/server/server.go b/server/server.go index 556e42c..08af9db 100644 --- a/server/server.go +++ b/server/server.go @@ -98,6 +98,7 @@ func (self *BBSServer) subscribeHandler(w http.ResponseWriter, r *http.Request) case <-ctx.Done(): fmt.Println("subscriber has disconnected") + close(s.data) return //ctx.Err() } } @@ -109,6 +110,8 @@ func (self *BBSServer) subscribeHandler(w http.ResponseWriter, r *http.Request) // block on the data channel, serializing and passing the data to the subscriber listen([]chan models.SocketData{s.data}, s.msgs) + fmt.Println("data listener is done!") + if errors.Is(err, context.Canceled) { return }