mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
实现跨服加入世界&玩家跨服在线迁移功能(部分完成)
This commit is contained in:
@@ -40,6 +40,11 @@ func NewMessageQueue(serverType string, appId string) (r *MessageQueue) {
|
||||
logger.Error("nats subscribe error: %v", err)
|
||||
return nil
|
||||
}
|
||||
_, err = r.natsConn.ChanSubscribe("ALL_SERVER_HK4E", r.natsMsgChan)
|
||||
if err != nil {
|
||||
logger.Error("nats subscribe error: %v", err)
|
||||
return nil
|
||||
}
|
||||
r.netMsgInput = make(chan *NetMsg, 1000)
|
||||
r.netMsgOutput = make(chan *NetMsg, 1000)
|
||||
r.cmdProtoMap = cmd.NewCmdProtoMap()
|
||||
@@ -85,8 +90,6 @@ func (m *MessageQueue) recvHandler() {
|
||||
}
|
||||
gameMsg.PayloadMessage = payloadMessage
|
||||
}
|
||||
case MsgTypeFight:
|
||||
case MsgTypeConnCtrl:
|
||||
}
|
||||
m.netMsgOutput <- netMsg
|
||||
}
|
||||
@@ -107,8 +110,6 @@ func (m *MessageQueue) sendHandler() {
|
||||
}
|
||||
gameMsg.PayloadMessageData = payloadMessageData
|
||||
}
|
||||
case MsgTypeFight:
|
||||
case MsgTypeConnCtrl:
|
||||
}
|
||||
// msgpack NetMsg
|
||||
netMsgData, err := msgpack.Marshal(netMsg)
|
||||
|
||||
@@ -6,6 +6,7 @@ const (
|
||||
MsgTypeGame = iota
|
||||
MsgTypeFight
|
||||
MsgTypeConnCtrl
|
||||
MsgTypeServer
|
||||
)
|
||||
|
||||
type NetMsg struct {
|
||||
@@ -15,6 +16,7 @@ type NetMsg struct {
|
||||
GameMsg *GameMsg `msgpack:"GameMsg"`
|
||||
FightMsg *FightMsg `msgpack:"FightMsg"`
|
||||
ConnCtrlMsg *ConnCtrlMsg `msgpack:"ConnCtrlMsg"`
|
||||
ServerMsg *ServerMsg `msgpack:"ServerMsg"`
|
||||
OriginServerType string `msgpack:"OriginServerType"`
|
||||
OriginServerAppId string `msgpack:"OriginServerAppId"`
|
||||
}
|
||||
@@ -35,17 +37,15 @@ type GameMsg struct {
|
||||
const (
|
||||
ClientRttNotify = iota
|
||||
ClientTimeNotify
|
||||
FightServerSelectNotify
|
||||
KickPlayerNotify
|
||||
)
|
||||
|
||||
type ConnCtrlMsg struct {
|
||||
UserId uint32 `msgpack:"UserId"`
|
||||
ClientRtt uint32 `msgpack:"ClientRtt"`
|
||||
ClientTime uint32 `msgpack:"ClientTime"`
|
||||
FightServerAppId string `msgpack:"FightServerAppId"`
|
||||
KickUserId uint32 `msgpack:"KickUserId"`
|
||||
KickReason uint32 `msgpack:"KickReason"`
|
||||
UserId uint32 `msgpack:"UserId"`
|
||||
ClientRtt uint32 `msgpack:"ClientRtt"`
|
||||
ClientTime uint32 `msgpack:"ClientTime"`
|
||||
KickUserId uint32 `msgpack:"KickUserId"`
|
||||
KickReason uint32 `msgpack:"KickReason"`
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -63,3 +63,37 @@ type FightMsg struct {
|
||||
AvatarGuid uint64 `msgpack:"AvatarGuid"`
|
||||
GateServerAppId string `msgpack:"GateServerAppId"`
|
||||
}
|
||||
|
||||
const (
|
||||
ServerAppidBindNotify = iota
|
||||
ServerUserOnlineStateChangeNotify
|
||||
ServerGetUserBaseInfoReq
|
||||
ServerGetUserBaseInfoRsp
|
||||
ServerUserGsChangeNotify
|
||||
)
|
||||
|
||||
type ServerMsg struct {
|
||||
FightServerAppId string `msgpack:"FightServerAppId"`
|
||||
UserId uint32 `msgpack:"UserId"`
|
||||
IsOnline bool `msgpack:"IsOnline"`
|
||||
UserBaseInfo *UserBaseInfo `msgpack:"UserBaseInfo"`
|
||||
GameServerAppId string `msgpack:"GameServerAppId"`
|
||||
JoinHostUserId uint32 `msgpack:"JoinHostUserId"`
|
||||
}
|
||||
|
||||
type OriginInfo struct {
|
||||
CmdName string `msgpack:"CmdName"`
|
||||
UserId uint32 `msgpack:"UserId"`
|
||||
}
|
||||
|
||||
type UserBaseInfo struct {
|
||||
OriginInfo *OriginInfo `msgpack:"OriginInfo"`
|
||||
UserId uint32 `msgpack:"UserId"`
|
||||
Nickname string `msgpack:"Nickname"`
|
||||
PlayerLevel uint32 `msgpack:"PlayerLevel"`
|
||||
MpSettingType uint8 `msgpack:"MpSettingType"`
|
||||
NameCardId uint32 `msgpack:"NameCardId"`
|
||||
Signature string `msgpack:"Signature"`
|
||||
HeadImageId uint32 `msgpack:"HeadImageId"`
|
||||
WorldPlayerNum uint32 `msgpack:"WorldPlayerNum"`
|
||||
}
|
||||
|
||||
@@ -46,3 +46,11 @@ func (m *MessageQueue) SendToPathfinding(appId string, netMsg *NetMsg) {
|
||||
netMsg.OriginServerAppId = originServerAppId
|
||||
m.netMsgInput <- netMsg
|
||||
}
|
||||
|
||||
func (m *MessageQueue) SendToAll(netMsg *NetMsg) {
|
||||
netMsg.Topic = "ALL_SERVER_HK4E"
|
||||
originServerType, originServerAppId := m.getOriginServer()
|
||||
netMsg.OriginServerType = originServerType
|
||||
netMsg.OriginServerAppId = originServerAppId
|
||||
m.netMsgInput <- netMsg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user