feat: add a ticker to manage broadcast timing
This commit is contained in:
parent
d256235c1b
commit
62fbb1d356
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue