Enha: roomlistupdate only on change; heartbeat every 2s

This commit is contained in:
Grail Finder
2025-07-10 11:35:56 +03:00
parent 85edb2d0ce
commit c946c07542
2 changed files with 10 additions and 5 deletions

View File

@ -63,8 +63,8 @@ func (broker *Broker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
broker.newClients <- messageChan
defer func() { broker.closingClients <- messageChan }()
ctx := r.Context()
// browser can close sse on its own
heartbeat := time.NewTicker(15 * time.Second)
// browser can close sse on its own; ping every 2s to prevent
heartbeat := time.NewTicker(2 * time.Second)
defer heartbeat.Stop()
for {
select {