Compare commits

..

24 commits

Author SHA1 Message Date
d0c3f263c1 fixup! add log message when removing stale client 2024-11-21 13:07:59 +01:00
0b6b680cce reorder staleClients.go 2024-11-21 09:44:48 +01:00
45b18ae7ab move websocket vars and const to vars.go 2024-11-21 09:44:48 +01:00
6100526610 add log message when removing stale client 2024-11-21 09:12:42 +01:00
71427f2879 fix logging 2024-11-21 09:12:42 +01:00
c1f158f42a merge ping and stale check 2024-11-21 09:12:42 +01:00
80ddfe57f4 add timeout consts in new file 2024-11-21 09:12:42 +01:00
e8cc2d1808 refactor: drop SendMessage() and merge into SendPermanentBroadCastMessage() 2024-11-21 09:12:42 +01:00
df98628d91 move ping from SendMessage() to RemoveStaleClients() 2024-11-21 08:27:15 +01:00
2faa95c162 remove client from list if stale 2024-11-20 22:01:56 +01:00
a0463ad817 comment updates 2024-11-20 21:52:08 +01:00
0ab0884508 add more Mutex Locks for Clients map 2024-11-20 21:51:58 +01:00
bf9b818940 move stale client check to RemoveStaleClients() 2024-11-20 21:50:43 +01:00
f4b1e7c808 add client.IsStale() 2024-11-20 21:26:17 +01:00
8295208a0b skip client after closing unresponsive client 2024-11-20 20:41:50 +01:00
18accba19a optimize ping/pong code 2024-11-20 20:39:32 +01:00
62b6ab81a5 remove duplicate logging 2024-11-20 20:33:26 +01:00
ed6902def0 init LastPong 2024-11-20 20:27:20 +01:00
6f60423c03 add more log output 2024-11-20 20:21:22 +01:00
409fd741dd move check for unresponsive clients to additional loops 2024-11-20 20:18:41 +01:00
15f6b0227a try to check for last ping connect 2024-11-20 20:15:24 +01:00
201e5779e6 add ping query 2024-11-20 20:07:29 +01:00
2d8816f4ba another try to remove vanished clients 2024-11-20 19:53:40 +01:00
370469de36 fix: remove client from active connections after write deadline
- add a constant for timeout duration in seconds
- set write deadline for client connections
- remove client from active connections on error
- log additional information when broadcasting fails

🤖
2024-11-20 14:07:00 +01:00
2 changed files with 4 additions and 4 deletions

View file

@ -11,10 +11,9 @@ import (
// Sends continous messages to all connected WebSocket clients
func SendPermanentBroadCastMessage() {
ticker := time.NewTicker(BROADCAST_INTERVAL * time.Second)
defer ticker.Stop()
tick := time.NewTicker(time.Second)
for range ticker.C {
for {
// Marshal the message into JSON format
jsonMessage, err := json.Marshal(shared.State)
if err != nil {
@ -33,5 +32,7 @@ func SendPermanentBroadCastMessage() {
}
}
mu.Unlock()
<-tick.C
}
}

View file

@ -7,7 +7,6 @@ import (
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
)
const BROADCAST_INTERVAL = 1
const SEND_TIMEOUT = 10
const STALE_CLIENT_TIMEOUT = 90
const STALE_CHECK_INTERVALL = 30