Compare commits
5 commits
6100526610
...
0c89ff3224
Author | SHA1 | Date | |
---|---|---|---|
0c89ff3224 | |||
83e5d68be5 | |||
2d5fa692d3 | |||
2e7a4627e7 | |||
4fc03c4180 |
3 changed files with 3 additions and 2 deletions
|
@ -25,6 +25,7 @@ func SendPermanentBroadCastMessage() {
|
|||
mu.Lock()
|
||||
for _, client := range Clients {
|
||||
// Send message to client
|
||||
|
||||
client.Conn.SetWriteDeadline(time.Now().Add(SEND_TIMEOUT * time.Second))
|
||||
err := client.Conn.WriteMessage(websocket.TextMessage, jsonMessage)
|
||||
if err != nil {
|
||||
|
|
|
@ -25,7 +25,7 @@ func isStale(client *models.WebsocketClient) bool {
|
|||
|
||||
// Check and remove stale clients
|
||||
func RemoveStaleClients() {
|
||||
ticker := time.NewTicker(STALE_CHECK_INTERVALL * time.Second)
|
||||
ticker := time.NewTicker(CHECK_INTERVALL * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for range ticker.C {
|
||||
|
|
|
@ -2,4 +2,4 @@ package websocket
|
|||
|
||||
const SEND_TIMEOUT = 10
|
||||
const STALE_CLIENT_TIMEOUT = 90
|
||||
const STALE_CHECK_INTERVALL = 30
|
||||
const CHECK_INTERVALL = 30
|
||||
|
|
Loading…
Reference in a new issue