1
This commit is contained in:
parent
1ad32bd8a4
commit
83dd3eb5f7
@ -3,56 +3,57 @@ package main
|
||||
import (
|
||||
"cs"
|
||||
"ss"
|
||||
"main/constant"
|
||||
)
|
||||
|
||||
type HandlerMgr struct {
|
||||
}
|
||||
|
||||
func (this *HandlerMgr) init() {
|
||||
ss.RegHandlerId(int(ss.SSMessageIdE__SS_Ping), WSP_LISTENER_HANDLER_ID)
|
||||
ss.RegHandlerId(int(ss.SSMessageIdE__SS_WSP_SocketDisconnect), WSP_LISTENER_HANDLER_ID)
|
||||
ss.RegHandlerId(int(ss.SSMessageIdE__SS_Ping), constant.WSP_LISTENER_HANDLER_ID)
|
||||
ss.RegHandlerId(int(ss.SSMessageIdE__SS_WSP_SocketDisconnect), constant.WSP_LISTENER_HANDLER_ID)
|
||||
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), PLAYER_MGR_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), PLAYER_MGR_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReconnect), PLAYER_MGR_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), constant.PLAYER_MGR_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), constant.PLAYER_MGR_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReconnect), constant.PLAYER_MGR_HANDLER_ID)
|
||||
|
||||
// 好友
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUser), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUserByAccountId), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddFriendRequest), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMAcceptFriendRequest), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMRejectFriendRequest), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMListPendingFriendRequest), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMListFriend), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDeleteFriendShip), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddBlacklist), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMRemoveBlacklist), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMInviteFriendMsg), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUser), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUserByAccountId), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddFriendRequest), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMAcceptFriendRequest), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMRejectFriendRequest), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMListPendingFriendRequest), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMListFriend), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDeleteFriendShip), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddBlacklist), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMRemoveBlacklist), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMInviteFriendMsg), constant.PLAYER_HANDLER_ID)
|
||||
// 公会
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildInfo), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMRecommendGuildList), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMCreateGuild), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMApplyToGuild), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMApprove), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReject), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMLeaveGuild), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDismissMember), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDisband), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchGuilds), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMApplyList), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildMembersList), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetNotice), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetName), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetAvatar), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetJoinCond), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetMemberLevel), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGetTopGuildsByTotalStars), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildInfo), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMRecommendGuildList), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMCreateGuild), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMApplyToGuild), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMApprove), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReject), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMLeaveGuild), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDismissMember), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDisband), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchGuilds), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMApplyList), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildMembersList), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetNotice), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetName), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetAvatar), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetJoinCond), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetMemberLevel), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGetTopGuildsByTotalStars), constant.PLAYER_HANDLER_ID)
|
||||
|
||||
// 聊天
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSendChatMsg), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReadMsgAndOpenChatNotify), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetCurrPrivateChatTarget), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMCloseChatNotify), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSendChatMsg), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReadMsgAndOpenChatNotify), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetCurrPrivateChatTarget), constant.PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMCloseChatNotify), constant.PLAYER_HANDLER_ID)
|
||||
}
|
||||
|
||||
func (this *HandlerMgr) unInit() {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"q5"
|
||||
"sort"
|
||||
"main/constant"
|
||||
. "main/global"
|
||||
)
|
||||
|
||||
@ -90,7 +91,7 @@ func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendin
|
||||
rspMsg := &cs.SMListPendingFriendRequest{}
|
||||
|
||||
for targetAccountId, friendRequest := range user.Friendships {
|
||||
if friendRequest.IsFriendship != FriendshipStatusPending {
|
||||
if friendRequest.IsFriendship != constant.FriendshipStatusPending {
|
||||
continue
|
||||
}
|
||||
profile := cacheMgr.GetPlayerProfile(targetAccountId)
|
||||
@ -112,7 +113,7 @@ func (p *Player) CMListFriend(hdr *f5.MsgHdr, msg *cs.CMListFriend) {
|
||||
|
||||
var friendIds []string
|
||||
for _, friendship := range user.Friendships {
|
||||
if friendship.FriendAccountId == accountId || friendship.IsFriendship != FriendshipStatusOK {
|
||||
if friendship.FriendAccountId == accountId || friendship.IsFriendship != constant.FriendshipStatusOK {
|
||||
continue
|
||||
}
|
||||
friendIds = append(friendIds, friendship.FriendAccountId)
|
||||
@ -250,7 +251,7 @@ func (p *Player) CMInviteFriendMsg(hdr *f5.MsgHdr, msg *cs.CMInviteFriendMsg) {
|
||||
rspMsg := new(cs.SMInviteFriendMsg)
|
||||
p2 := playerMgr.GetPlayerByAccountId(msg.GetInviteAccountId())
|
||||
if p2 == nil {
|
||||
rspMsg.Errcode = proto.Int32(ERR_CODE_FRIEND_NO_EXISTS)
|
||||
rspMsg.Errcode = proto.Int32(constant.ERR_CODE_FRIEND_NO_EXISTS)
|
||||
rspMsg.Errmsg = proto.String("friend no exists")
|
||||
p.SendMsg(rspMsg)
|
||||
} else {
|
||||
@ -266,13 +267,13 @@ func (p *Player) CMSendChatMsg(hdr *f5.MsgHdr, msg *cs.CMSendChatMsg) {
|
||||
}
|
||||
|
||||
switch msg.GetChatChannel() {
|
||||
case kCCWorld:
|
||||
case constant.CCWorld:
|
||||
chatMgr.ProcWorldChat(p, msg)
|
||||
case kCCPrivate:
|
||||
case constant.CCPrivate:
|
||||
chatMgr.ProcPrivateChat(p, msg)
|
||||
case kCCGuild:
|
||||
case constant.CCGuild:
|
||||
chatMgr.ProcGuildChat(p, msg)
|
||||
case kCCTeam:
|
||||
case constant.CCTeam:
|
||||
chatMgr.ProcTeamChat(p, msg)
|
||||
default:
|
||||
return
|
||||
@ -290,7 +291,7 @@ func (p *Player) CMReadMsgAndOpenChatNotify(hdr *f5.MsgHdr, msg *cs.CMReadMsgAnd
|
||||
return
|
||||
}
|
||||
p.chatChannel = int(msg.GetCurrChannel())
|
||||
if p.chatChannel == kCCPrivate {
|
||||
if p.chatChannel == constant.CCPrivate {
|
||||
p.SyncPrivateChatRedPoint()
|
||||
}
|
||||
|
||||
@ -302,10 +303,10 @@ func (p *Player) CMReadMsgAndOpenChatNotify(hdr *f5.MsgHdr, msg *cs.CMReadMsgAnd
|
||||
}
|
||||
chatChannelLastId := uint64(v.GetValue())
|
||||
switch chatChannel {
|
||||
case kCCWorld:
|
||||
case constant.CCWorld:
|
||||
p.worldChannelLastId = chatChannelLastId
|
||||
chatMgr.SyncWorldChatMsg(p)
|
||||
case kCCGuild:
|
||||
case constant.CCGuild:
|
||||
p.guildChannelLastId = chatChannelLastId
|
||||
chatMgr.SyncGuildChatMsg(p)
|
||||
default:
|
||||
@ -327,7 +328,7 @@ func (p *Player) MarkNewMsg() {
|
||||
}
|
||||
|
||||
func IsValidChatChannel(chatChannel int32) bool {
|
||||
return chatChannel > kCCBegin && chatChannel < kCCEnd
|
||||
return chatChannel > constant.CCBegin && chatChannel < constant.CCEnd
|
||||
}
|
||||
|
||||
// CMGuildInfo 公会信息
|
||||
@ -432,12 +433,12 @@ func (p *Player) CMApplyList(hdr *f5.MsgHdr, msg *cs.CMApplyList) {
|
||||
guild := guildMgr.GetGuildByAccountId(p.accountId)
|
||||
if guild != nil {
|
||||
for accountId, isJoin := range guild.PendingReqs {
|
||||
if isJoin != PendingReqIsJoinGuildStatusDefault {
|
||||
if isJoin != constant.PendingReqIsJoinGuildStatusDefault {
|
||||
continue
|
||||
}
|
||||
member := &GuildMember{
|
||||
AccountId: accountId,
|
||||
Level: q5.ToInt32(GuildMemberLevelDefault),
|
||||
Level: q5.ToInt32(constant.GuildMemberLevelDefault),
|
||||
}
|
||||
rspMember := p.FillMFGuildMember(member)
|
||||
if rspMember != nil {
|
||||
@ -689,7 +690,7 @@ func (p *Player) CMGuildMembersList(hdr *f5.MsgHdr, msg *cs.CMGuildMembersList)
|
||||
|
||||
guild := guildMgr.GetGuildByAccountId(p.accountId)
|
||||
if guild == nil {
|
||||
errCode := q5.ToInt32(ERR_CODE_CREATE_GUILD_DB_FAIL)
|
||||
errCode := q5.ToInt32(constant.ERR_CODE_CREATE_GUILD_DB_FAIL)
|
||||
errMsg := "No guild"
|
||||
rspMsg.Errcode = &errCode
|
||||
rspMsg.Errmsg = &errMsg
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"mt"
|
||||
"q5"
|
||||
"main/constant"
|
||||
. "main/global"
|
||||
)
|
||||
|
||||
@ -58,7 +59,7 @@ func (this *PlayerMgr) init() {
|
||||
}
|
||||
{
|
||||
f5.GetJsStyleDb().OrmSelectOne(
|
||||
GAME_DB,
|
||||
constant.GAME_DB,
|
||||
"t_user",
|
||||
[][]string{
|
||||
[]string{"account_id", "100"},
|
||||
@ -136,7 +137,7 @@ func (this *PlayerMgr) CMLoginResult(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.Htt
|
||||
AvatarHead: q5.ToInt32(resObj.Info.AvatarHead),
|
||||
Star: q5.ToInt32(resObj.Info.Star),
|
||||
Rank: q5.ToInt32(resObj.Info.Rank),
|
||||
OnlineStatus: OnlineStatus,
|
||||
OnlineStatus: constant.OnlineStatus,
|
||||
LastLoginTime: q5.ToInt32(resObj.Info.LastLoginTime),
|
||||
}
|
||||
if len(resObj.Info.HistorySeasons) == 1 {
|
||||
@ -211,22 +212,22 @@ func (this *PlayerMgr) addSocketHash(wsp f5.WspCliConn, p *Player) {
|
||||
func (this *PlayerMgr) GetOnlineStatus(accountId string) int32 {
|
||||
player := this.GetPlayerByAccountId(accountId)
|
||||
if player != nil {
|
||||
return OnlineStatus
|
||||
return constant.OnlineStatus
|
||||
}
|
||||
return OnlineStatusOff
|
||||
return constant.OnlineStatusOff
|
||||
}
|
||||
|
||||
func (this *PlayerMgr) CMReconnect(hdr *f5.MsgHdr, msg *cs.CMReconnect) {
|
||||
hum := this.GetPlayerByAccountId(msg.GetAccountId())
|
||||
rspMsg := &cs.SMReconnect{}
|
||||
if hum == nil {
|
||||
rspMsg.Errcode = proto.Int32(ERR_CODE_RECONNECT_PLAYER_NO_EXISTS)
|
||||
rspMsg.Errcode = proto.Int32(constant.ERR_CODE_RECONNECT_PLAYER_NO_EXISTS)
|
||||
rspMsg.Errmsg = proto.String("player no exists")
|
||||
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
return
|
||||
}
|
||||
if hum.GetSessionId() != msg.GetSessionId() {
|
||||
rspMsg.Errcode = proto.Int32(ERR_CODE_RECONNECT_PLAYER_SESSION_ID_NO_VALID)
|
||||
rspMsg.Errcode = proto.Int32(constant.ERR_CODE_RECONNECT_PLAYER_SESSION_ID_NO_VALID)
|
||||
rspMsg.Errmsg = proto.String("session_id no valid")
|
||||
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
return
|
||||
@ -267,7 +268,7 @@ func (this *PlayerMgr) GetRemotePlayerInfo(player *Player, cb func(errCode int32
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(rsp.GetRawData()), &resObj)
|
||||
if err != nil {
|
||||
cb(ERR_CODE_GUILD_API_ERROR, "SetNameConsume Api服务器JSON解析错误", nil)
|
||||
cb(constant.ERR_CODE_GUILD_API_ERROR, "SetNameConsume Api服务器JSON解析错误", nil)
|
||||
f5.GetSysLog().Info("SetNameConsume Api服务器JSON解析错误:%s\n", err)
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user