1
This commit is contained in:
parent
f6fc262f0e
commit
5d871e61ce
@ -48,15 +48,38 @@ type PlayerMgr interface {
|
|||||||
GetOnlineStatus(string) int32
|
GetOnlineStatus(string) int32
|
||||||
OnSocketClose(f5.WspCliConn)
|
OnSocketClose(f5.WspCliConn)
|
||||||
GetPlayers() map[string]Player
|
GetPlayers() map[string]Player
|
||||||
|
UnBindSocket(f5.WspCliConn)
|
||||||
|
BindSocket(f5.WspCliConn, Player)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Friendship interface {
|
||||||
|
IsFriendship() int32
|
||||||
|
FriendAccountId() string
|
||||||
|
}
|
||||||
|
|
||||||
|
type FriendBlackList interface {
|
||||||
|
GetAccountId() string
|
||||||
|
IsRemoved() int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type User interface {
|
type User interface {
|
||||||
|
GetFriendships() map[string]Friendship
|
||||||
|
GetFriendBlackList() map[string]FriendBlackList
|
||||||
}
|
}
|
||||||
|
|
||||||
type FriendMgr interface {
|
type FriendMgr interface {
|
||||||
GetFriendByAccountId(account1Id, account2Id string) User
|
GetFriendByAccountId(account1Id, account2Id string) User
|
||||||
AddUser(string, User)
|
AddUser(string, User)
|
||||||
|
GetUser(string) User
|
||||||
LoadUserFriendships(user User, where [][]string)
|
LoadUserFriendships(user User, where [][]string)
|
||||||
|
SearchUsers(accountId, username string, sinceId int64, cb func(errCode int32, errMsg string, lastId int64, listFriend []*PlayerProfile))
|
||||||
|
SearchByAccountId(accountId string, cb func(errCode int32, errMsg string, playerProfile *PlayerProfile))
|
||||||
|
AddFriendRequest(account1Id string, account2Id string, cb func(errCode int32, errMsg string))
|
||||||
|
AcceptFriendRequest(account1Id string, account2Id string, cb func(errCode int32, errMsg string))
|
||||||
|
RejectFriendRequest(account1Id string, account2Id string, cb func(errCode int32, errMsg string))
|
||||||
|
DeleteFriendShip(account1Id, account2Id string, cb func(errCode int32, errMsg string))
|
||||||
|
AddBlacklist(account1Id string, account2Id string, cb func(errCode int32, errMsg string))
|
||||||
|
RemoveBlacklist(account1Id string, account2Id string, cb func(errCode int32, errMsg string))
|
||||||
}
|
}
|
||||||
|
|
||||||
type Guild interface {
|
type Guild interface {
|
||||||
@ -77,6 +100,19 @@ type CacheMgr interface {
|
|||||||
GetProfileByAccountId(accountId string, cb func(err error, profile *PlayerProfile))
|
GetProfileByAccountId(accountId string, cb func(err error, profile *PlayerProfile))
|
||||||
GetPlayerProfile(accountId string) *PlayerProfile
|
GetPlayerProfile(accountId string) *PlayerProfile
|
||||||
LoadUserProfile(string)
|
LoadUserProfile(string)
|
||||||
|
AsyncGetUsers(accountIds []string, cb func(bool))
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatMgr interface {
|
||||||
|
ProcWorldChat(p Player, msg *cs.CMSendChatMsg)
|
||||||
|
ProcGuildChat(p Player, msg *cs.CMSendChatMsg)
|
||||||
|
ProcTeamChat(p Player, msg *cs.CMSendChatMsg)
|
||||||
|
ProcPrivateChat(p Player, msg *cs.CMSendChatMsg)
|
||||||
|
FillSMUpdateChatRedPointNotify(p Player, msg *cs.SMUpdateChatRedPointNotify)
|
||||||
|
FillSMUpdatePrivateChatRedPointNotify(p Player, msg *cs.SMUpdatePrivateChatRedPointNotify)
|
||||||
|
SyncWorldChatMsg(p Player)
|
||||||
|
SyncGuildChatMsg(p Player)
|
||||||
|
SyncPrivateChatMsg(p Player)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerProfile struct {
|
type PlayerProfile struct {
|
||||||
|
@ -2,6 +2,7 @@ package friend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"main/constant"
|
"main/constant"
|
||||||
|
"main/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
@ -32,6 +33,14 @@ func NewUser(accountId string) *User {
|
|||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) GetFriendships() map[string]common.Friendship {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetFriendBlackList() map[string]common.FriendBlackList {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (u *User) AddFriendRequest(account2Id string, IsFriendship int32, requestTime int64) {
|
func (u *User) AddFriendRequest(account2Id string, IsFriendship int32, requestTime int64) {
|
||||||
friendShip := &Friendship{
|
friendShip := &Friendship{
|
||||||
FriendAccountId: account2Id,
|
FriendAccountId: account2Id,
|
||||||
|
@ -22,6 +22,7 @@ var wspListener common.WspListener
|
|||||||
var friendMgr common.FriendMgr
|
var friendMgr common.FriendMgr
|
||||||
var guildMgr common.GuildMgr
|
var guildMgr common.GuildMgr
|
||||||
var cacheMgr common.CacheMgr
|
var cacheMgr common.CacheMgr
|
||||||
|
var chatMgr common.ChatMgr
|
||||||
|
|
||||||
func GetPlayerMgr() common.PlayerMgr {
|
func GetPlayerMgr() common.PlayerMgr {
|
||||||
return playerMgr
|
return playerMgr
|
||||||
@ -39,6 +40,10 @@ func GetCacheMgr() common.CacheMgr {
|
|||||||
return cacheMgr
|
return cacheMgr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetChatMgr() common.ChatMgr {
|
||||||
|
return chatMgr
|
||||||
|
}
|
||||||
|
|
||||||
func GetWspListener() common.WspListener {
|
func GetWspListener() common.WspListener {
|
||||||
return wspListener
|
return wspListener
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"q5"
|
"q5"
|
||||||
"sort"
|
"sort"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
|
"main/common"
|
||||||
. "main/global"
|
. "main/global"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,27 +31,79 @@ func (p *Player) GetSessionId() string {
|
|||||||
return p.sessionId
|
return p.sessionId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Player) GetAvatarUrl() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) GetName() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) GetHeroId() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) GetPing() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) GetHeadFrame() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) GetPrivateTargetAccountId() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) IncrPrivateChatLastId() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) IsOnline() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) SetGuildChannelLastId(int64) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) SetWorldChannelLastId(int64) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player) GetChatChannel() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Player)GetWorldChannelLastId() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this* Player) GetGuildChannelLastId() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Player) SendMsg(rspMsg proto.Message) {
|
func (p *Player) SendMsg(rspMsg proto.Message) {
|
||||||
GetWspListener().SendProxyMsg(p.socket.Conn, p.socket.SocketHandle, rspMsg)
|
GetWspListener().SendProxyMsg(p.socket.Conn, p.socket.SocketHandle, rspMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) ReBind(socket f5.WspCliConn) {
|
func (p *Player) ReBind(socket f5.WspCliConn) {
|
||||||
if p.socket.IsValid() {
|
if p.socket.IsValid() {
|
||||||
delete(playerMgr.socketHash, p.socket)
|
GetPlayerMgr().UnBindSocket(p.socket)
|
||||||
}
|
}
|
||||||
p.socket = socket
|
p.socket = socket
|
||||||
playerMgr.socketHash[p.socket] = p
|
GetPlayerMgr().BindSocket(socket, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMSearchUser 搜索用户
|
// CMSearchUser 搜索用户
|
||||||
func (p *Player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
|
func (p *Player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
|
||||||
sinceId := msg.GetSinceId()
|
sinceId := msg.GetSinceId()
|
||||||
searchUsername := msg.GetUsername()
|
searchUsername := msg.GetUsername()
|
||||||
friendMgr.SearchUsers(
|
GetFriendMgr().SearchUsers(
|
||||||
p.accountId,
|
p.accountId,
|
||||||
searchUsername,
|
searchUsername,
|
||||||
sinceId,
|
sinceId,
|
||||||
func(errCode int32, errMsg string, lastId int64, listFriend []*PlayerProfile) {
|
func(errCode int32, errMsg string, lastId int64, listFriend []*common.PlayerProfile) {
|
||||||
f5.GetSysLog().Info("CMSearchUser username:[%s], count:%d, \n", searchUsername, len(listFriend))
|
f5.GetSysLog().Info("CMSearchUser username:[%s], count:%d, \n", searchUsername, len(listFriend))
|
||||||
rspMsg := new(cs.SMSearchUser)
|
rspMsg := new(cs.SMSearchUser)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
@ -69,8 +122,8 @@ func (p *Player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
|
|||||||
|
|
||||||
// CMSearchUserByAccountId 搜索指定用户
|
// CMSearchUserByAccountId 搜索指定用户
|
||||||
func (p *Player) CMSearchUserByAccountId(hdr *f5.MsgHdr, msg *cs.CMSearchUserByAccountId) {
|
func (p *Player) CMSearchUserByAccountId(hdr *f5.MsgHdr, msg *cs.CMSearchUserByAccountId) {
|
||||||
friendMgr.SearchByAccountId(msg.GetAccountId(),
|
GetFriendMgr().SearchByAccountId(msg.GetAccountId(),
|
||||||
func(errCode int32, errMsg string, playerProfile *PlayerProfile) {
|
func(errCode int32, errMsg string, playerProfile *common.PlayerProfile) {
|
||||||
rspMsg := new(cs.SMSearchUserByAccountId)
|
rspMsg := new(cs.SMSearchUserByAccountId)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
rspMsg.Errcode = &errCode
|
rspMsg.Errcode = &errCode
|
||||||
@ -87,14 +140,14 @@ func (p *Player) CMSearchUserByAccountId(hdr *f5.MsgHdr, msg *cs.CMSearchUserByA
|
|||||||
// CMListPendingFriendRequest 等待验证的好友请求
|
// CMListPendingFriendRequest 等待验证的好友请求
|
||||||
func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendingFriendRequest) {
|
func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendingFriendRequest) {
|
||||||
accountId := p.accountId
|
accountId := p.accountId
|
||||||
user := friendMgr.GetUser(accountId)
|
user := GetFriendMgr().GetUser(accountId)
|
||||||
rspMsg := &cs.SMListPendingFriendRequest{}
|
rspMsg := &cs.SMListPendingFriendRequest{}
|
||||||
|
|
||||||
for targetAccountId, friendRequest := range user.Friendships {
|
for targetAccountId, friendRequest := range user.GetFriendships() {
|
||||||
if friendRequest.IsFriendship != constant.FriendshipStatusPending {
|
if friendRequest.IsFriendship() != constant.FriendshipStatusPending {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
profile := cacheMgr.GetPlayerProfile(targetAccountId)
|
profile := GetCacheMgr().GetPlayerProfile(targetAccountId)
|
||||||
if profile == nil {
|
if profile == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -109,24 +162,24 @@ func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendin
|
|||||||
// CMListFriend 我的好友列表
|
// CMListFriend 我的好友列表
|
||||||
func (p *Player) CMListFriend(hdr *f5.MsgHdr, msg *cs.CMListFriend) {
|
func (p *Player) CMListFriend(hdr *f5.MsgHdr, msg *cs.CMListFriend) {
|
||||||
accountId := p.accountId
|
accountId := p.accountId
|
||||||
user := friendMgr.GetUser(accountId)
|
user := GetFriendMgr().GetUser(accountId)
|
||||||
|
|
||||||
var friendIds []string
|
var friendIds []string
|
||||||
for _, friendship := range user.Friendships {
|
for _, friendship := range user.GetFriendships() {
|
||||||
if friendship.FriendAccountId == accountId || friendship.IsFriendship != constant.FriendshipStatusOK {
|
if friendship.FriendAccountId() == accountId || friendship.IsFriendship() != constant.FriendshipStatusOK {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
friendIds = append(friendIds, friendship.FriendAccountId)
|
friendIds = append(friendIds, friendship.FriendAccountId())
|
||||||
}
|
}
|
||||||
|
|
||||||
rspMsg := &cs.SMListFriend{}
|
rspMsg := &cs.SMListFriend{}
|
||||||
rspMsg.Users = make([]*cs.MFUser, len(friendIds))
|
rspMsg.Users = make([]*cs.MFUser, len(friendIds))
|
||||||
cacheMgr.AsyncGetUsers(friendIds, func(ok bool) {
|
GetCacheMgr().AsyncGetUsers(friendIds, func(ok bool) {
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, fid := range friendIds {
|
for _, fid := range friendIds {
|
||||||
userProfile := cacheMgr.GetPlayerProfile(fid)
|
userProfile := GetCacheMgr().GetPlayerProfile(fid)
|
||||||
rspUser := p.FillMFUser(userProfile)
|
rspUser := p.FillMFUser(userProfile)
|
||||||
rspMsg.Users = append(rspMsg.Users, rspUser)
|
rspMsg.Users = append(rspMsg.Users, rspUser)
|
||||||
}
|
}
|
||||||
@ -138,12 +191,12 @@ func (p *Player) CMListFriend(hdr *f5.MsgHdr, msg *cs.CMListFriend) {
|
|||||||
func (p *Player) CMBlacklist(hdr *f5.MsgHdr, msg *cs.CMBlacklist) {
|
func (p *Player) CMBlacklist(hdr *f5.MsgHdr, msg *cs.CMBlacklist) {
|
||||||
rspMsg := &cs.SMBlacklist{}
|
rspMsg := &cs.SMBlacklist{}
|
||||||
accountId := p.accountId
|
accountId := p.accountId
|
||||||
player := friendMgr.GetUser(accountId)
|
player := GetFriendMgr().GetUser(accountId)
|
||||||
for _, blackList := range player.FriendBlackList {
|
for _, blackList := range player.GetFriendBlackList() {
|
||||||
if blackList.IsRemoved != 0 {
|
if blackList.IsRemoved() != 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
blockedPlayerProfile := cacheMgr.GetPlayerProfile(blackList.AccountId)
|
blockedPlayerProfile := GetCacheMgr().GetPlayerProfile(blackList.GetAccountId())
|
||||||
if blockedPlayerProfile == nil {
|
if blockedPlayerProfile == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -157,7 +210,7 @@ func (p *Player) CMBlacklist(hdr *f5.MsgHdr, msg *cs.CMBlacklist) {
|
|||||||
func (p *Player) CMAddFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAddFriendRequest) {
|
func (p *Player) CMAddFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAddFriendRequest) {
|
||||||
user1Id := p.accountId
|
user1Id := p.accountId
|
||||||
user2Id := msg.GetTargetAccountId()
|
user2Id := msg.GetTargetAccountId()
|
||||||
friendMgr.AddFriendRequest(user1Id, user2Id,
|
GetFriendMgr().AddFriendRequest(user1Id, user2Id,
|
||||||
func(errCode int32, errMsg string) {
|
func(errCode int32, errMsg string) {
|
||||||
rspMsg := new(cs.SMAddFriendRequest)
|
rspMsg := new(cs.SMAddFriendRequest)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
@ -173,7 +226,7 @@ func (p *Player) CMAddFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAddFriendRequest)
|
|||||||
func (p *Player) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAcceptFriendRequest) {
|
func (p *Player) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAcceptFriendRequest) {
|
||||||
user1Id := p.accountId
|
user1Id := p.accountId
|
||||||
user2Id := msg.GetTargetAccountId()
|
user2Id := msg.GetTargetAccountId()
|
||||||
friendMgr.AcceptFriendRequest(user1Id, user2Id,
|
GetFriendMgr().AcceptFriendRequest(user1Id, user2Id,
|
||||||
func(errCode int32, errMsg string) {
|
func(errCode int32, errMsg string) {
|
||||||
rspMsg := new(cs.SMAcceptFriendRequest)
|
rspMsg := new(cs.SMAcceptFriendRequest)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
@ -189,7 +242,7 @@ func (p *Player) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAcceptFriendReq
|
|||||||
func (p *Player) CMRejectFriendRequest(hdr *f5.MsgHdr, msg *cs.CMRejectFriendRequest) {
|
func (p *Player) CMRejectFriendRequest(hdr *f5.MsgHdr, msg *cs.CMRejectFriendRequest) {
|
||||||
user1Id := p.accountId
|
user1Id := p.accountId
|
||||||
user2Id := msg.GetTargetAccountId()
|
user2Id := msg.GetTargetAccountId()
|
||||||
friendMgr.RejectFriendRequest(user1Id, user2Id,
|
GetFriendMgr().RejectFriendRequest(user1Id, user2Id,
|
||||||
func(errCode int32, errMsg string) {
|
func(errCode int32, errMsg string) {
|
||||||
rspMsg := new(cs.SMRejectFriendRequest)
|
rspMsg := new(cs.SMRejectFriendRequest)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
@ -205,7 +258,7 @@ func (p *Player) CMRejectFriendRequest(hdr *f5.MsgHdr, msg *cs.CMRejectFriendReq
|
|||||||
func (p *Player) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *cs.CMDeleteFriendShip) {
|
func (p *Player) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *cs.CMDeleteFriendShip) {
|
||||||
user1Id := p.accountId
|
user1Id := p.accountId
|
||||||
user2Id := msg.GetTargetAccountId()
|
user2Id := msg.GetTargetAccountId()
|
||||||
friendMgr.DeleteFriendShip(user1Id, user2Id,
|
GetFriendMgr().DeleteFriendShip(user1Id, user2Id,
|
||||||
func(errCode int32, errMsg string) {
|
func(errCode int32, errMsg string) {
|
||||||
rspMsg := new(cs.SMDeleteFriendShip)
|
rspMsg := new(cs.SMDeleteFriendShip)
|
||||||
rspMsg.Errcode = &errCode
|
rspMsg.Errcode = &errCode
|
||||||
@ -218,7 +271,7 @@ func (p *Player) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *cs.CMDeleteFriendShip)
|
|||||||
func (p *Player) CMAddBlacklist(hdr *f5.MsgHdr, msg *cs.CMAddBlacklist) {
|
func (p *Player) CMAddBlacklist(hdr *f5.MsgHdr, msg *cs.CMAddBlacklist) {
|
||||||
user1Id := p.accountId
|
user1Id := p.accountId
|
||||||
user2Id := msg.GetTargetAccountId()
|
user2Id := msg.GetTargetAccountId()
|
||||||
friendMgr.AddBlacklist(user1Id, user2Id,
|
GetFriendMgr().AddBlacklist(user1Id, user2Id,
|
||||||
func(errCode int32, errMsg string) {
|
func(errCode int32, errMsg string) {
|
||||||
rspMsg := new(cs.SMAddBlacklist)
|
rspMsg := new(cs.SMAddBlacklist)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
@ -234,7 +287,7 @@ func (p *Player) CMAddBlacklist(hdr *f5.MsgHdr, msg *cs.CMAddBlacklist) {
|
|||||||
func (p *Player) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *cs.CMRemoveBlacklist) {
|
func (p *Player) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *cs.CMRemoveBlacklist) {
|
||||||
user1Id := p.accountId
|
user1Id := p.accountId
|
||||||
user2Id := msg.GetTargetAccountId()
|
user2Id := msg.GetTargetAccountId()
|
||||||
friendMgr.RemoveBlacklist(user1Id, user2Id,
|
GetFriendMgr().RemoveBlacklist(user1Id, user2Id,
|
||||||
func(errCode int32, errMsg string) {
|
func(errCode int32, errMsg string) {
|
||||||
rspMsg := new(cs.SMRemoveBlacklist)
|
rspMsg := new(cs.SMRemoveBlacklist)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
@ -249,7 +302,7 @@ func (p *Player) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *cs.CMRemoveBlacklist) {
|
|||||||
// CMInviteFriendMsg 邀请好友加入队伍
|
// CMInviteFriendMsg 邀请好友加入队伍
|
||||||
func (p *Player) CMInviteFriendMsg(hdr *f5.MsgHdr, msg *cs.CMInviteFriendMsg) {
|
func (p *Player) CMInviteFriendMsg(hdr *f5.MsgHdr, msg *cs.CMInviteFriendMsg) {
|
||||||
rspMsg := new(cs.SMInviteFriendMsg)
|
rspMsg := new(cs.SMInviteFriendMsg)
|
||||||
p2 := playerMgr.GetPlayerByAccountId(msg.GetInviteAccountId())
|
p2 := GetPlayerMgr().GetPlayerByAccountId(msg.GetInviteAccountId())
|
||||||
if p2 == nil {
|
if p2 == nil {
|
||||||
rspMsg.Errcode = proto.Int32(constant.ERR_CODE_FRIEND_NO_EXISTS)
|
rspMsg.Errcode = proto.Int32(constant.ERR_CODE_FRIEND_NO_EXISTS)
|
||||||
rspMsg.Errmsg = proto.String("friend no exists")
|
rspMsg.Errmsg = proto.String("friend no exists")
|
||||||
@ -268,13 +321,13 @@ func (p *Player) CMSendChatMsg(hdr *f5.MsgHdr, msg *cs.CMSendChatMsg) {
|
|||||||
|
|
||||||
switch msg.GetChatChannel() {
|
switch msg.GetChatChannel() {
|
||||||
case constant.CCWorld:
|
case constant.CCWorld:
|
||||||
chatMgr.ProcWorldChat(p, msg)
|
GetChatMgr().ProcWorldChat(p, msg)
|
||||||
case constant.CCPrivate:
|
case constant.CCPrivate:
|
||||||
chatMgr.ProcPrivateChat(p, msg)
|
GetChatMgr().ProcPrivateChat(p, msg)
|
||||||
case constant.CCGuild:
|
case constant.CCGuild:
|
||||||
chatMgr.ProcGuildChat(p, msg)
|
GetChatMgr().ProcGuildChat(p, msg)
|
||||||
case constant.CCTeam:
|
case constant.CCTeam:
|
||||||
chatMgr.ProcTeamChat(p, msg)
|
GetChatMgr().ProcTeamChat(p, msg)
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -282,7 +335,7 @@ func (p *Player) CMSendChatMsg(hdr *f5.MsgHdr, msg *cs.CMSendChatMsg) {
|
|||||||
|
|
||||||
func (p *Player) SyncPrivateChatRedPoint() {
|
func (p *Player) SyncPrivateChatRedPoint() {
|
||||||
msg := &cs.SMUpdatePrivateChatRedPointNotify{}
|
msg := &cs.SMUpdatePrivateChatRedPointNotify{}
|
||||||
chatMgr.FillSMUpdatePrivateChatRedPointNotify(p, msg)
|
GetChatMgr().FillSMUpdatePrivateChatRedPointNotify(p, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMReadMsgAndOpenChatNotify 读取聊天消息列表并且开启聊天通知
|
// CMReadMsgAndOpenChatNotify 读取聊天消息列表并且开启聊天通知
|
||||||
@ -305,10 +358,10 @@ func (p *Player) CMReadMsgAndOpenChatNotify(hdr *f5.MsgHdr, msg *cs.CMReadMsgAnd
|
|||||||
switch chatChannel {
|
switch chatChannel {
|
||||||
case constant.CCWorld:
|
case constant.CCWorld:
|
||||||
p.worldChannelLastId = chatChannelLastId
|
p.worldChannelLastId = chatChannelLastId
|
||||||
chatMgr.SyncWorldChatMsg(p)
|
GetChatMgr().SyncWorldChatMsg(p)
|
||||||
case constant.CCGuild:
|
case constant.CCGuild:
|
||||||
p.guildChannelLastId = chatChannelLastId
|
p.guildChannelLastId = chatChannelLastId
|
||||||
chatMgr.SyncGuildChatMsg(p)
|
GetChatMgr().SyncGuildChatMsg(p)
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -318,12 +371,12 @@ func (p *Player) CMReadMsgAndOpenChatNotify(hdr *f5.MsgHdr, msg *cs.CMReadMsgAnd
|
|||||||
// CMSetCurrPrivateChatTarget 设置当前私聊目标
|
// CMSetCurrPrivateChatTarget 设置当前私聊目标
|
||||||
func (p *Player) CMSetCurrPrivateChatTarget(hdr *f5.MsgHdr, msg *cs.CMSetCurrPrivateChatTarget) {
|
func (p *Player) CMSetCurrPrivateChatTarget(hdr *f5.MsgHdr, msg *cs.CMSetCurrPrivateChatTarget) {
|
||||||
p.privateTargetAccountId = msg.GetTargetAccountId()
|
p.privateTargetAccountId = msg.GetTargetAccountId()
|
||||||
chatMgr.SyncPrivateChatMsg(p)
|
GetChatMgr().SyncPrivateChatMsg(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) MarkNewMsg() {
|
func (p *Player) MarkNewMsg() {
|
||||||
rspMsg := &cs.SMUpdateChatRedPointNotify{}
|
rspMsg := &cs.SMUpdateChatRedPointNotify{}
|
||||||
chatMgr.FillSMUpdateChatRedPointNotify(p, rspMsg)
|
GetChatMgr().FillSMUpdateChatRedPointNotify(p, rspMsg)
|
||||||
p.SendMsg(rspMsg)
|
p.SendMsg(rspMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +391,7 @@ func (p *Player) CMGuildInfo(hdr *f5.MsgHdr, msg *cs.CMGuildInfo) {
|
|||||||
accountId = msg.GetAccountId()
|
accountId = msg.GetAccountId()
|
||||||
}
|
}
|
||||||
rspMsg := new(cs.SMGuildInfo)
|
rspMsg := new(cs.SMGuildInfo)
|
||||||
guild := guildMgr.GetGuildByAccountId(accountId)
|
guild := GetGuildMgr().GetGuildByAccountId(accountId)
|
||||||
if guild != nil {
|
if guild != nil {
|
||||||
rspMsg.Guild = p.FillMFGuild(guild)
|
rspMsg.Guild = p.FillMFGuild(guild)
|
||||||
}
|
}
|
||||||
@ -348,7 +401,7 @@ func (p *Player) CMGuildInfo(hdr *f5.MsgHdr, msg *cs.CMGuildInfo) {
|
|||||||
// CMRecommendGuildList 推荐公会列表
|
// CMRecommendGuildList 推荐公会列表
|
||||||
func (p *Player) CMRecommendGuildList(hdr *f5.MsgHdr, msg *cs.CMRecommendGuildList) {
|
func (p *Player) CMRecommendGuildList(hdr *f5.MsgHdr, msg *cs.CMRecommendGuildList) {
|
||||||
rspMsg := new(cs.SMRecommendGuildList)
|
rspMsg := new(cs.SMRecommendGuildList)
|
||||||
rspMsg.RecommendGuilds = p.FillMFGuilds(guildMgr.RandomGuilds())
|
rspMsg.RecommendGuilds = p.FillMFGuilds(GetGuildMgr().RandomGuilds())
|
||||||
p.SendMsg(rspMsg)
|
p.SendMsg(rspMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user