Compare commits

...

2 commits

Author SHA1 Message Date
0c89ff3224 add log message when removing stale client 2024-11-21 08:57:43 +01:00
83e5d68be5 fix logging 2024-11-21 08:57:31 +01:00
2 changed files with 3 additions and 1 deletions

View file

@ -29,7 +29,7 @@ func SendPermanentBroadCastMessage() {
client.Conn.SetWriteDeadline(time.Now().Add(SEND_TIMEOUT * time.Second))
err := client.Conn.WriteMessage(websocket.TextMessage, jsonMessage)
if err != nil {
helper.Logger.Info("Error broadcasting to client:", "msg", err, "host", client.RealIP, "clients", len(Clients))
helper.Logger.Error("Error broadcasting to client:", "msg", err, "host", client.RealIP, "clients", len(Clients))
}
}
mu.Unlock()

View file

@ -3,6 +3,7 @@ package websocket
import (
"time"
"git.smsvc.net/pomodoro/GoTomato/internal/helper"
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
"github.com/gorilla/websocket"
)
@ -33,6 +34,7 @@ func RemoveStaleClients() {
if !sendPing(client) || isStale(client) {
client.Conn.Close()
delete(Clients, client.Conn.LocalAddr())
helper.Logger.Info("Removed stale client", "host", client.RealIP, "clients", len(Clients))
}
}
mu.Unlock()