修正keepalive包的处理逻辑问题

This commit is contained in:
lwch
2021-08-20 10:12:49 +08:00
parent c7f73d7d80
commit a9a2b65a83
2 changed files with 4 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ func (c *client) run() {
logging.Error("read message from %s: %v", c.id, err) logging.Error("read message from %s: %v", c.id, err)
return return
} }
c.updated = time.Now()
c.parent.onMessage(msg) c.parent.onMessage(msg)
} }
} }

View File

@@ -83,6 +83,9 @@ func (h *Handler) readHandshake(c *network.Conn) (string, error) {
// onMessage forward message // onMessage forward message
func (h *Handler) onMessage(msg *network.Msg) { func (h *Handler) onMessage(msg *network.Msg) {
if msg.GetXType() == network.Msg_keepalive {
return
}
to := msg.GetTo() to := msg.GetTo()
h.RLock() h.RLock()
cli := h.clients[to] cli := h.clients[to]
@@ -91,10 +94,6 @@ func (h *Handler) onMessage(msg *network.Msg) {
logging.Error("client %s not found", to) logging.Error("client %s not found", to)
return return
} }
cli.updated = time.Now()
if msg.GetXType() == network.Msg_keepalive {
return
}
h.msgHook(msg) h.msgHook(msg)
cli.writeMessage(msg) cli.writeMessage(msg)
} }