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 {
|
||||
mu.Lock()
|
||||
for _, client := range Clients {
|
||||
// send ping and check for last pong
|
||||
if !sendPing(client) || isStale(client) {
|
||||
// send ping
|
||||
if !sendPing(client) {
|
||||
client.Conn.Close()
|
||||
delete(Clients, client.Conn.LocalAddr())
|
||||
}
|
||||
|
||||
// check for last pong
|
||||
if isStale(client) {
|
||||
client.Conn.Close()
|
||||
delete(Clients, client.Conn.LocalAddr())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue