玩家管理模块接入redis,已完整实现好友、多人世界的跨服交互功能

This commit is contained in:
flswld
2022-12-29 22:42:57 +08:00
parent 0a2e13fad3
commit 6fd3d6a349
25 changed files with 1094 additions and 407 deletions

View File

@@ -13,6 +13,7 @@ type Config struct {
HttpPort int32 `toml:"http_port"`
Logger Logger `toml:"logger"`
Database Database `toml:"database"`
Redis Redis `toml:"redis"`
Hk4e Hk4e `toml:"hk4e"`
MQ MQ `toml:"mq"`
}
@@ -30,6 +31,11 @@ type Database struct {
Url string `toml:"url"`
}
type Redis struct {
Addr string `toml:"addr"`
Password string `toml:"password"`
}
// Hk4e 原神相关
type Hk4e struct {
KcpPort int32 `toml:"kcp_port"`

View File

@@ -3,10 +3,10 @@ package mq
import pb "google.golang.org/protobuf/proto"
const (
MsgTypeGame = iota
MsgTypeFight
MsgTypeConnCtrl
MsgTypeServer
MsgTypeGame = iota // 来自客户端的游戏消息
MsgTypeFight // 战斗服务器消息
MsgTypeConnCtrl // GATE客户端连接信息消息
MsgTypeServer // 服务器之间转发的消息
)
type NetMsg struct {
@@ -22,8 +22,7 @@ type NetMsg struct {
}
const (
NormalMsg = iota
UserOfflineNotify
NormalMsg = iota // 正常的游戏消息
)
type GameMsg struct {
@@ -35,9 +34,10 @@ type GameMsg struct {
}
const (
ClientRttNotify = iota
ClientTimeNotify
KickPlayerNotify
ClientRttNotify = iota // 客户端网络时延上报
ClientTimeNotify // 客户端本地时间上报
KickPlayerNotify // 通知GATE剔除玩家
UserOfflineNotify // 玩家离线通知GS
)
type ConnCtrlMsg struct {
@@ -49,10 +49,10 @@ type ConnCtrlMsg struct {
}
const (
AddFightRoutine = iota
DelFightRoutine
FightRoutineAddEntity
FightRoutineDelEntity
AddFightRoutine = iota // 添加战斗实例
DelFightRoutine // 删除战斗实例
FightRoutineAddEntity // 战斗实例添加实体
FightRoutineDelEntity // 战斗实例删除实体
)
type FightMsg struct {
@@ -65,20 +65,27 @@ type FightMsg struct {
}
const (
ServerAppidBindNotify = iota
ServerUserOnlineStateChangeNotify
ServerGetUserBaseInfoReq
ServerGetUserBaseInfoRsp
ServerUserGsChangeNotify
ServerAppidBindNotify = iota // 玩家连接绑定的各个服务器appid通知
ServerUserOnlineStateChangeNotify // 广播玩家上线和离线状态以及所在GS的appid
ServerUserBaseInfoReq // 跨服玩家基础数据请求
ServerUserBaseInfoRsp // 跨服玩家基础数据响应
ServerUserGsChangeNotify // 跨服玩家迁移通知
ServerUserMpReq // 跨服多人世界相关请求
ServerUserMpRsp // 跨服多人世界相关响应
ServerChatMsgNotify // 跨服玩家聊天消息通知
ServerAddFriendNotify // 跨服添加好友通知
)
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"`
FightServerAppId string `msgpack:"FightServerAppId"`
UserId uint32 `msgpack:"UserId"`
IsOnline bool `msgpack:"IsOnline"`
UserBaseInfo *UserBaseInfo `msgpack:"UserBaseInfo"`
GameServerAppId string `msgpack:"GameServerAppId"`
JoinHostUserId uint32 `msgpack:"JoinHostUserId"`
UserMpInfo *UserMpInfo `msgpack:"UserMpInfo"`
ChatMsgInfo *ChatMsgInfo `msgpack:"ChatMsgInfo"`
AddFriendInfo *AddFriendInfo `msgpack:"AddFriendInfo"`
}
type OriginInfo struct {
@@ -96,4 +103,32 @@ type UserBaseInfo struct {
Signature string `msgpack:"Signature"`
HeadImageId uint32 `msgpack:"HeadImageId"`
WorldPlayerNum uint32 `msgpack:"WorldPlayerNum"`
WorldLevel uint32 `msgpack:"WorldLevel"`
Birthday []uint8 `msgpack:"Birthday"`
}
type UserMpInfo struct {
OriginInfo *OriginInfo `msgpack:"OriginInfo"`
HostUserId uint32 `msgpack:"HostUserId"`
ApplyUserId uint32 `msgpack:"ApplyUserId"`
ApplyPlayerOnlineInfo *UserBaseInfo `msgpack:"ApplyPlayerOnlineInfo"`
ApplyOk bool `msgpack:"ApplyOk"`
Agreed bool `msgpack:"Agreed"`
HostNickname string `msgpack:"HostNickname"`
}
type ChatMsgInfo struct {
Time uint32 `msgpack:"Time"`
ToUid uint32 `msgpack:"ToUid"`
Uid uint32 `msgpack:"Uid"`
IsRead bool `msgpack:"IsRead"`
MsgType uint8 `msgpack:"MsgType"`
Text string `msgpack:"Text"`
Icon uint32 `msgpack:"Icon"`
}
type AddFriendInfo struct {
OriginInfo *OriginInfo `msgpack:"OriginInfo"`
TargetUserId uint32 `msgpack:"TargetUserId"`
ApplyPlayerOnlineInfo *UserBaseInfo `msgpack:"ApplyPlayerOnlineInfo"`
}