mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:52:27 +08:00
优化登录、离线、服务器重启等会话连接问题
This commit is contained in:
@@ -61,7 +61,7 @@ func (m *MessageQueue) recvHandler() {
|
||||
switch netMsg.MsgType {
|
||||
case MsgTypeGame:
|
||||
gameMsg := netMsg.GameMsg
|
||||
if netMsg.EventId == NormalMsg || netMsg.EventId == UserRegNotify {
|
||||
if netMsg.EventId == NormalMsg {
|
||||
// protobuf PayloadMessage
|
||||
payloadMessage := m.cmdProtoMap.GetProtoObjByCmdId(gameMsg.CmdId)
|
||||
if payloadMessage == nil {
|
||||
@@ -76,6 +76,7 @@ func (m *MessageQueue) recvHandler() {
|
||||
gameMsg.PayloadMessage = payloadMessage
|
||||
}
|
||||
case MsgTypeFight:
|
||||
case MsgTypeConnCtrl:
|
||||
}
|
||||
m.netMsgOutput <- netMsg
|
||||
}
|
||||
@@ -97,6 +98,7 @@ func (m *MessageQueue) sendHandler() {
|
||||
gameMsg.PayloadMessageData = payloadMessageData
|
||||
}
|
||||
case MsgTypeFight:
|
||||
case MsgTypeConnCtrl:
|
||||
}
|
||||
// msgpack NetMsg
|
||||
netMsgData, err := msgpack.Marshal(netMsg)
|
||||
|
||||
@@ -5,35 +5,45 @@ import pb "google.golang.org/protobuf/proto"
|
||||
const (
|
||||
MsgTypeGame = iota
|
||||
MsgTypeFight
|
||||
MsgTypeConnCtrl
|
||||
)
|
||||
|
||||
type NetMsg struct {
|
||||
MsgType uint8 `msgpack:"MsgType"`
|
||||
EventId uint16 `msgpack:"EventId"`
|
||||
Topic string `msgpack:"-"`
|
||||
GameMsg *GameMsg `msgpack:"GameMsg"`
|
||||
FightMsg *FightMsg `msgpack:"FightMsg"`
|
||||
MsgType uint8 `msgpack:"MsgType"`
|
||||
EventId uint16 `msgpack:"EventId"`
|
||||
Topic string `msgpack:"-"`
|
||||
GameMsg *GameMsg `msgpack:"GameMsg"`
|
||||
FightMsg *FightMsg `msgpack:"FightMsg"`
|
||||
ConnCtrlMsg *ConnCtrlMsg `msgpack:"ConnCtrlMsg"`
|
||||
}
|
||||
|
||||
const (
|
||||
NormalMsg = iota
|
||||
UserRegNotify
|
||||
UserLoginNotify
|
||||
UserOfflineNotify
|
||||
ClientRttNotify
|
||||
ClientTimeNotify
|
||||
)
|
||||
|
||||
type GameMsg struct {
|
||||
UserId uint32 `msgpack:"UserId"`
|
||||
CmdId uint16 `msgpack:"CmdId"`
|
||||
ClientSeq uint32 `msgpack:"ClientSeq"`
|
||||
ClientRtt uint32 `msgpack:"ClientRtt"`
|
||||
ClientTime uint32 `msgpack:"ClientTime"`
|
||||
PayloadMessage pb.Message `msgpack:"-"`
|
||||
PayloadMessageData []byte `msgpack:"PayloadMessageData"`
|
||||
}
|
||||
|
||||
const (
|
||||
ClientRttNotify = iota
|
||||
ClientTimeNotify
|
||||
KickPlayerNotify
|
||||
)
|
||||
|
||||
type ConnCtrlMsg struct {
|
||||
UserId uint32 `msgpack:"UserId"`
|
||||
ClientRtt uint32 `msgpack:"ClientRtt"`
|
||||
ClientTime uint32 `msgpack:"ClientTime"`
|
||||
KickUserId uint32 `msgpack:"KickUserId"`
|
||||
KickReason uint32 `msgpack:"KickReason"`
|
||||
}
|
||||
|
||||
const (
|
||||
AddFightRoutine = iota
|
||||
DelFightRoutine
|
||||
|
||||
Reference in New Issue
Block a user