From 58bd53cb576a37bcf5d652215e88c20fb64d185f Mon Sep 17 00:00:00 2001 From: lwch Date: Tue, 24 Aug 2021 16:09:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0server=E7=AB=AF=E7=9A=84from?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=94=B9=E5=86=99=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/server/handler/handler.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/server/handler/handler.go b/code/server/handler/handler.go index 46f854d..e233336 100644 --- a/code/server/handler/handler.go +++ b/code/server/handler/handler.go @@ -170,13 +170,18 @@ func (h *Handler) msgHook(msg *network.Msg, from, to *client) { h.links[id] = pair h.Unlock() case network.Msg_disconnect: + id := msg.GetXDisconnect().GetId() if from != nil { - from.removeLink(msg.GetXDisconnect().GetId()) + from.removeLink(id) } if to != nil { - to.removeLink(msg.GetXDisconnect().GetId()) + to.removeLink(id) } + h.Lock() + delete(h.links, id) + h.Unlock() } + msg.From = from.trimID } // closeAll close all links from client