diff --git a/internal/websocket/broadcast.go b/internal/websocket/broadcast.go index 02b7f0a..2fd5754 100644 --- a/internal/websocket/broadcast.go +++ b/internal/websocket/broadcast.go @@ -10,6 +10,7 @@ import ( // sends continous messages to all connected WebSocket clients. func SendPermanentBroadCastMessage() { + tick := time.NewTicker(time.Second) for { // Marshal the message into JSON format jsonMessage, err := json.Marshal(shared.Message) @@ -25,6 +26,6 @@ func SendPermanentBroadCastMessage() { // The client is responsible for closing itself on error } } - time.Sleep(time.Second) + <-tick.C } }