split ping sending and pong check
This commit is contained in:
parent
1e9b7fbb79
commit
bb141bffb8
1 changed files with 8 additions and 2 deletions
|
@ -31,8 +31,14 @@ func RemoveStaleClients() {
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
for _, client := range Clients {
|
for _, client := range Clients {
|
||||||
// send ping and check for last pong
|
// send ping
|
||||||
if !sendPing(client) || isStale(client) {
|
if !sendPing(client) {
|
||||||
|
client.Conn.Close()
|
||||||
|
delete(Clients, client.Conn.LocalAddr())
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for last pong
|
||||||
|
if isStale(client) {
|
||||||
client.Conn.Close()
|
client.Conn.Close()
|
||||||
delete(Clients, client.Conn.LocalAddr())
|
delete(Clients, client.Conn.LocalAddr())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue