feat: update logging for client connect and disconnect

- update logging to use ws.RemoteAddr()

🤖
This commit is contained in:
Sebastian Mark 2024-10-30 10:19:07 +01:00
parent 0ee955189c
commit f4fd37c551
2 changed files with 2 additions and 2 deletions

View file

@ -17,7 +17,7 @@ func handleClientCommands(c models.WebsocketClient) {
_, message, err := ws.ReadMessage()
if err != nil {
log.Info("Client disconnected:", "msg", err, "host", ws.NetConn().RemoteAddr(), "clients", len(Clients)-1)
log.Info("Client disconnected:", "msg", err, "host", ws.RemoteAddr(), "clients", len(Clients)-1)
delete(Clients, ws.LocalAddr())
break
}

View file

@ -29,7 +29,7 @@ func HandleConnection(w http.ResponseWriter, r *http.Request) {
}
defer ws.Close()
log.Info("Client connected", "host", ws.NetConn().RemoteAddr(), "clients", len(Clients)+1)
log.Info("Client connected", "host", ws.RemoteAddr(), "clients", len(Clients)+1)
// Register the new client
client := models.WebsocketClient{