修改心跳逻辑

This commit is contained in:
liwei1dao 2023-02-22 18:45:22 +08:00
parent f1b11de7f2
commit 25d8e8bb72

View File

@ -78,21 +78,21 @@ locp:
break locp break locp
} else { } else {
// this.gateway.Debugf("----------1 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType) // this.gateway.Debugf("----------1 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
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,
})
this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30))
continue
}
var code pb.ErrorCode var code pb.ErrorCode
code, err = this.secAuth(msg) code, err = this.secAuth(msg)
if err == nil { 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,
})
this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30))
continue
}
// this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType) // this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
if err := this.messageDistribution(msg); err != nil { if err := this.messageDistribution(msg); err != nil {
this.gateway.Errorf("messageDistribution err:%v", err) this.gateway.Errorf("messageDistribution err:%v", err)