优化心跳代码
This commit is contained in:
parent
705b16a362
commit
c7d421e421
@ -78,6 +78,17 @@ locp:
|
|||||||
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,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
if err := this.messageDistribution(msg); err != nil {
|
if err := this.messageDistribution(msg); err != nil {
|
||||||
go this.Close()
|
go this.Close()
|
||||||
break locp
|
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)
|
this.gateway.Errorf("last timestamp:%v more than 30s", timestamp)
|
||||||
return pb.ErrorCode_TimestampTimeout, fmt.Errorf("sec key expire")
|
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
|
//只有login的时候才需要设置Data
|
||||||
if msg.MainType == string(comm.ModuleUser) && msg.SubType == "login" {
|
if msg.MainType == string(comm.ModuleUser) && msg.SubType == "login" {
|
||||||
|
Loading…
Reference in New Issue
Block a user