From c7d421e4219dddf928feb165a02274a655cb1702 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Sun, 29 Jan 2023 15:02:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BF=83=E8=B7=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/agent.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index e6742a871..3b9b6100e 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -78,6 +78,17 @@ locp: var code pb.ErrorCode code, err = this.secAuth(msg) if err == nil { + if msg.MainType == string(comm.ModuleGate) { //心跳消息 + data, _ := anypb.New(&pb.GatewayHeartbeatResp{ + Timestamp: configure.Now().Unix(), + }) + this.WriteMsg(&pb.UserMessage{ + MainType: string(comm.ModuleGate), + SubType: "heartbeat", + Data: data, + }) + continue + } if err := this.messageDistribution(msg); err != nil { go this.Close() break locp @@ -150,17 +161,6 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (code pb.ErrorCode, err e this.gateway.Errorf("last timestamp:%v more than 30s", timestamp) return pb.ErrorCode_TimestampTimeout, fmt.Errorf("sec key expire") } - if msg.MainType == string(comm.ModuleGate) { //心跳消息 - data, _ := anypb.New(&pb.GatewayHeartbeatResp{ - Timestamp: configure.Now().Unix(), - }) - this.WriteMsg(&pb.UserMessage{ - MainType: string(comm.ModuleGate), - SubType: "heartbeat", - Data: data, - }) - return - } //只有login的时候才需要设置Data if msg.MainType == string(comm.ModuleUser) && msg.SubType == "login" {