feat: add a ticker to manage broadcast timing

This commit is contained in:
Sebastian Mark 2024-10-25 23:15:48 +02:00
parent d256235c1b
commit 62fbb1d356

View file

@ -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
}
}