Compare commits

..

5 commits

3 changed files with 3 additions and 2 deletions

View file

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

View file

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

View file

@ -2,4 +2,4 @@ package websocket
const SEND_TIMEOUT = 10
const STALE_CLIENT_TIMEOUT = 90
const STALE_CHECK_INTERVALL = 30
const CHECK_INTERVALL = 30