feat: implement stale client removal after timeout

- add goroutine to remove stale clients from the connection pool
- update client struct to track `LastPong` time
- set write deadline for websocket connections
- move package variables and const to `vars.go`
- log additional information when broadcasting errors

🤖
This commit is contained in:
Sebastian Mark 2024-11-20 14:07:00 +01:00
parent e8e65c4f3a
commit ab2e8c161d
7 changed files with 75 additions and 21 deletions

View file

@ -21,6 +21,7 @@ func handleClientCommands(c models.WebsocketClient) {
_, message, err := ws.ReadMessage()
if err != nil {
// remove client on error/disconnect
delete(Clients, ws.LocalAddr())
helper.Logger.Info("Client disconnected:", "msg", err, "host", c.RealIP, "clients", len(Clients))
break