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