mirror of
https://github.com/lwch/natpass
synced 2025-10-06 05:46:49 +08:00
客户端忽略io timeout错误,服务器端定时发心跳
This commit is contained in:
@@ -90,3 +90,19 @@ func (c *client) closeLink(id string) {
|
||||
func (c *client) is(id string, idx uint32) bool {
|
||||
return c.parent.id == id && c.idx == idx
|
||||
}
|
||||
|
||||
func (c *client) keepalive() {
|
||||
var msg network.Msg
|
||||
msg.From = "server"
|
||||
msg.To = c.parent.id
|
||||
msg.ToIdx = c.idx
|
||||
msg.XType = network.Msg_keepalive
|
||||
for {
|
||||
time.Sleep(10 * time.Second)
|
||||
err := c.writeMessage(&msg)
|
||||
if err != nil {
|
||||
logging.Error("send keepalive: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user