From 5b7455160555670aefde14253411ba6f2c85b18b Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Sun, 29 Jan 2023 18:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0wocket=20=E6=B8=85=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/agent.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 3b9b6100e..6ebd23dd7 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -70,6 +70,7 @@ locp: go this.Close() break locp } + this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30)) if err = proto.Unmarshal(data, msg); err != nil { this.gateway.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err) go this.Close() @@ -177,9 +178,14 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (code pb.ErrorCode, err e } msg.Data = ad } else { - if msg.MainType != string(comm.ModuleNotify) && this.UserId() == "" { - this.gateway.Errorf("[%v.%v] Agent UId empty", msg.MainType, msg.SubType) - return pb.ErrorCode_AgentUidEmpty, fmt.Errorf("no login") + switch msg.MainType { + case string(comm.ModuleNotify), string(comm.ModuleGate): + return pb.ErrorCode_Success, nil + default: + if this.UserId() == "" { + this.gateway.Errorf("[%v.%v] Agent UId empty", msg.MainType, msg.SubType) + return pb.ErrorCode_AgentUidEmpty, fmt.Errorf("no login") + } } } return pb.ErrorCode_Success, nil