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

@ -54,6 +54,7 @@ func Start() {
r := http.NewServeMux()
r.HandleFunc("/", websocket.HandleConnection)
go websocket.SendPermanentBroadCastMessage()
go websocket.RemoveStaleClients()
helper.Logger.Info("GoTomato started", "version", metadata.GoTomatoVersion)
helper.Logger.Info("Websocket listening", "address", listen)