修正server端的connect_req和connect_rep消息没有保持同一条通路的问题

This commit is contained in:
lwch
2021-08-24 15:44:56 +08:00
parent d7a0b9309c
commit 85c20d294b

View File

@@ -159,8 +159,7 @@ func (h *Handler) msgHook(msg *network.Msg, toCli *client) {
fromCli := h.clients[from] fromCli := h.clients[from]
h.RUnlock() h.RUnlock()
switch msg.GetXType() { switch msg.GetXType() {
case network.Msg_connect_rep: case network.Msg_connect_req:
if msg.GetCrep().GetOk() {
id := msg.GetCrep().GetId() id := msg.GetCrep().GetId()
var pair [2]*client var pair [2]*client
if fromCli != nil { if fromCli != nil {
@@ -174,7 +173,6 @@ func (h *Handler) msgHook(msg *network.Msg, toCli *client) {
h.Lock() h.Lock()
h.links[id] = pair h.links[id] = pair
h.Unlock() h.Unlock()
}
case network.Msg_disconnect: case network.Msg_disconnect:
if fromCli != nil { if fromCli != nil {
fromCli.removeLink(msg.GetXDisconnect().GetId()) fromCli.removeLink(msg.GetXDisconnect().GetId())