mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 20:58:14 -05:00
增加WebSocket的ping包
This commit is contained in:
parent
1fa9fb0b48
commit
ab9dfbc578
@ -185,6 +185,7 @@ func (cp *commonPage) ws(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
count := 0
|
||||
for {
|
||||
dao.SortedServerLock.RLock()
|
||||
err = conn.WriteJSON(dao.SortedServerList)
|
||||
@ -192,6 +193,10 @@ func (cp *commonPage) ws(c *gin.Context) {
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
count += 1
|
||||
if count%4 == 0 {
|
||||
conn.WriteMessage(websocket.PingMessage, []byte{})
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user