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" {