im聊天
This commit is contained in:
parent
23ff7da74d
commit
6a0709efd4
@ -25,6 +25,7 @@ func (this *App) Init() {
|
||||
playerMgr.init()
|
||||
friendMgr.init()
|
||||
guildMgr.init()
|
||||
chatMgr.init()
|
||||
wspListener.init()
|
||||
httpListener.init()
|
||||
}
|
||||
|
17
server/imserver/chat.go
Normal file
17
server/imserver/chat.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cs"
|
||||
)
|
||||
|
||||
type ChatUserRec struct {
|
||||
HasUnreadMsg bool
|
||||
Dirty bool
|
||||
Users map[string]*ChatMsgRec
|
||||
}
|
||||
|
||||
type ChatMsgRec struct {
|
||||
CurrID uint64
|
||||
LastID uint64
|
||||
ChatMsgList []*cs.MFChatMsg
|
||||
}
|
274
server/imserver/chatmgr.go
Normal file
274
server/imserver/chatmgr.go
Normal file
@ -0,0 +1,274 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cs"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ChatMgr struct {
|
||||
pm *PlayerMgr
|
||||
fm *FriendsMgr
|
||||
gm *GuildMgr
|
||||
|
||||
worldMsgRec ChatMsgRec
|
||||
guildMsgRec map[int64]*ChatMsgRec
|
||||
privateChatUsers map[string]*ChatUserRec
|
||||
|
||||
WorldMsgId uint64
|
||||
GuildMsgId uint64
|
||||
TmpMsgId uint64
|
||||
}
|
||||
|
||||
func NewChatMgr(pm *PlayerMgr, fm *FriendsMgr, gm *GuildMgr) *ChatMgr {
|
||||
cm := &ChatMgr{
|
||||
pm: pm,
|
||||
fm: fm,
|
||||
gm: gm,
|
||||
worldMsgRec: ChatMsgRec{},
|
||||
guildMsgRec: make(map[int64]*ChatMsgRec),
|
||||
privateChatUsers: make(map[string]*ChatUserRec),
|
||||
}
|
||||
// Default values
|
||||
cm.WorldMsgId = 1000
|
||||
cm.GuildMsgId = 1000
|
||||
cm.TmpMsgId = 1000
|
||||
|
||||
return cm
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) init() {}
|
||||
|
||||
func (cm *ChatMgr) FillMFChatMsg(msg *cs.MFChatMsg, accountId *string,
|
||||
msgAutoId uint64, chatChannel int32, msgType int32, msgBody *string) {
|
||||
|
||||
msg.MsgUuid = &msgAutoId
|
||||
msg.Sender = accountId
|
||||
msg.ChatChannel = &chatChannel
|
||||
msg.MsgType = &msgType
|
||||
msg.MsgBody = msgBody
|
||||
|
||||
unixSec := time.Now().Unix()
|
||||
msg.SendTime = &unixSec
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) FillSMUpdateChatRedPointNotify(p *Player, msg *cs.SMUpdateChatRedPointNotify) {
|
||||
// New messages flag
|
||||
if cm.worldMsgRec.CurrID > p.worldChannelLastId {
|
||||
msg.HasUnreadMsgChannels = append(msg.HasUnreadMsgChannels, kCCWorld)
|
||||
}
|
||||
guildId := cm.gm.GetGuildIdByAccountId(p.accountId)
|
||||
if guildId > 0 {
|
||||
if msgRec, exists := cm.guildMsgRec[guildId]; exists {
|
||||
if msgRec.CurrID > p.guildChannelLastId {
|
||||
msg.HasUnreadMsgChannels = append(msg.HasUnreadMsgChannels, kCCGuild)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
userRec := cm.GetChatUser(&p.accountId)
|
||||
if userRec != nil {
|
||||
if userRec.Dirty {
|
||||
userRec.HasUnreadMsg = false
|
||||
userRec.Dirty = false
|
||||
}
|
||||
if userRec.HasUnreadMsg {
|
||||
msg.HasUnreadMsgChannels = append(msg.HasUnreadMsgChannels, kCCPrivate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) FillSMUpdatePrivateChatRedPointNotify(p *Player, msg *cs.SMUpdatePrivateChatRedPointNotify) {
|
||||
userRec := cm.GetChatUser(&p.accountId)
|
||||
if userRec == nil {
|
||||
return
|
||||
}
|
||||
for accountId, msgRec := range userRec.Users {
|
||||
if msgRec.CurrID < msgRec.LastID {
|
||||
msg.HasUnreadMsgAccounts = append(msg.HasUnreadMsgAccounts, accountId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) ProcWorldChat(p *Player, msg *cs.CMSendChatMsg) {
|
||||
accountId := p.GetAccountId()
|
||||
chatMsg := new(cs.MFChatMsg)
|
||||
cm.WorldMsgId++
|
||||
cm.FillMFChatMsg(chatMsg, &accountId, cm.WorldMsgId, *msg.ChatChannel, *msg.MsgType, msg.MsgBody)
|
||||
|
||||
cm.worldMsgRec.CurrID = cm.WorldMsgId
|
||||
cm.worldMsgRec.ChatMsgList = append(cm.worldMsgRec.ChatMsgList, chatMsg)
|
||||
|
||||
// TraversePlayer
|
||||
for _, p2 := range cm.pm.GetPlayers() {
|
||||
cm.SyncWorldChatMsg(p2)
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) ProcGuildChat(p *Player, msg *cs.CMSendChatMsg) {
|
||||
guild := cm.gm.GetGuildByAccountId(p.accountId)
|
||||
if guild == nil {
|
||||
return
|
||||
}
|
||||
guildId := guild.GuildId
|
||||
cm.GuildMsgId++
|
||||
|
||||
chatMsg := new(cs.MFChatMsg)
|
||||
cm.FillMFChatMsg(chatMsg, &p.accountId, cm.GuildMsgId, *msg.ChatChannel, *msg.MsgType, msg.MsgBody)
|
||||
|
||||
if msgRec, exists := cm.guildMsgRec[guildId]; exists {
|
||||
msgRec.ChatMsgList = append(msgRec.ChatMsgList, chatMsg)
|
||||
} else {
|
||||
msgRec := &ChatMsgRec{}
|
||||
msgRec.CurrID = cm.GuildMsgId
|
||||
cm.guildMsgRec[guildId] = msgRec
|
||||
}
|
||||
|
||||
// TraverseMember
|
||||
for _, member := range guild.Members {
|
||||
guildMember := playerMgr.getPlayerByAccountId(member.AccountId)
|
||||
if guildMember != nil {
|
||||
cm.SyncGuildChatMsg(guildMember)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) ProcPrivateChat(p *Player, msg *cs.CMSendChatMsg) {
|
||||
targetAccountId := msg.GetTargetAccountId()
|
||||
if p.accountId == targetAccountId {
|
||||
return
|
||||
}
|
||||
// 确定是否好友
|
||||
targetAccount := cm.fm.GetFriendByAccountId(p.accountId, targetAccountId)
|
||||
if targetAccount == nil {
|
||||
return
|
||||
}
|
||||
|
||||
chatMsg := new(cs.MFChatMsg)
|
||||
cm.FillMFChatMsg(chatMsg, &p.accountId, 0, *msg.ChatChannel, *msg.MsgType, msg.MsgBody)
|
||||
cm.AddChatUser(p.accountId, msg.GetTargetAccountId(), chatMsg, p.IncrPrivateChatLastId())
|
||||
cm.SyncPrivateChatMsg(p)
|
||||
|
||||
// 聊天好友在线
|
||||
targetPlayer := cm.pm.getPlayerByAccountId(targetAccountId)
|
||||
if targetPlayer != nil {
|
||||
cm.SyncPrivateChatMsg(targetPlayer)
|
||||
} else {
|
||||
cm.AddChatUser(targetAccountId, p.GetAccountId(), chatMsg, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) SyncWorldChatMsg(p *Player) {
|
||||
if p.chatChannel == kCCWorld {
|
||||
notifyMsg := &cs.SMChatMsgNotify{}
|
||||
for _, chatMsg := range cm.worldMsgRec.ChatMsgList {
|
||||
if chatMsg.GetMsgUuid() > p.worldChannelLastId {
|
||||
notifyMsg.MsgList = append(notifyMsg.MsgList, chatMsg)
|
||||
p.worldChannelLastId = chatMsg.GetMsgUuid()
|
||||
}
|
||||
}
|
||||
if len(notifyMsg.MsgList) > 0 {
|
||||
p.SendMsg(notifyMsg)
|
||||
}
|
||||
return
|
||||
}
|
||||
p.MarkNewMsg()
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) SyncPrivateChatMsg(p *Player) {
|
||||
if p.chatChannel == kCCPrivate {
|
||||
chatUser := cm.GetChatUser(&p.accountId)
|
||||
if chatUser == nil {
|
||||
return
|
||||
}
|
||||
|
||||
notifyMsg := &cs.SMChatMsgNotify{}
|
||||
for accountId, chatMsgRec := range chatUser.Users {
|
||||
if accountId == p.privateTargetAccountId {
|
||||
for _, chatMsg := range chatMsgRec.ChatMsgList {
|
||||
if *chatMsg.MsgUuid > chatMsgRec.CurrID {
|
||||
notifyMsg.MsgList = append(notifyMsg.MsgList, chatMsg)
|
||||
chatMsgRec.CurrID = *chatMsg.MsgUuid
|
||||
chatUser.Dirty = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(notifyMsg.MsgList) > 0 {
|
||||
p.SendMsg(notifyMsg)
|
||||
}
|
||||
}
|
||||
p.MarkNewMsg()
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) SyncGuildChatMsg(p *Player) {
|
||||
guildId := cm.gm.GetGuildIdByAccountId(p.accountId)
|
||||
if guildId <= 0 {
|
||||
return
|
||||
}
|
||||
msgRec, exists := cm.guildMsgRec[guildId]
|
||||
if !exists {
|
||||
return
|
||||
}
|
||||
|
||||
if p.chatChannel == kCCGuild {
|
||||
notifyMsg := &cs.SMChatMsgNotify{}
|
||||
for _, chatMsg := range msgRec.ChatMsgList {
|
||||
if chatMsg.GetMsgUuid() > p.guildChannelLastId {
|
||||
notifyMsg.MsgList = append(notifyMsg.MsgList, chatMsg)
|
||||
p.guildChannelLastId = chatMsg.GetMsgUuid()
|
||||
}
|
||||
}
|
||||
if len(notifyMsg.MsgList) > 0 {
|
||||
p.SendMsg(notifyMsg)
|
||||
}
|
||||
return
|
||||
}
|
||||
p.MarkNewMsg()
|
||||
// player.SyncRedPoint()
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) AddChatUser(senderAccountId, receiverAccountId string, chatMsg *cs.MFChatMsg, lastId uint64) {
|
||||
chatMsgCopy := new(cs.MFChatMsg)
|
||||
*chatMsgCopy = *chatMsg
|
||||
chatMsgCopy.MsgUuid = &lastId
|
||||
|
||||
if _, exists := cm.privateChatUsers[senderAccountId]; !exists {
|
||||
cm.privateChatUsers[senderAccountId] = &ChatUserRec{}
|
||||
}
|
||||
|
||||
userRec := cm.privateChatUsers[senderAccountId]
|
||||
userRec.Dirty = true
|
||||
userRec.HasUnreadMsg = true
|
||||
|
||||
if _, exists := cm.privateChatUsers[senderAccountId].Users[receiverAccountId]; !exists {
|
||||
cm.privateChatUsers[senderAccountId].Users[receiverAccountId] = &ChatMsgRec{}
|
||||
}
|
||||
|
||||
receiverUserRec := cm.privateChatUsers[senderAccountId].Users[receiverAccountId]
|
||||
receiverUserRec.LastID = lastId
|
||||
receiverUserRec.ChatMsgList = append(receiverUserRec.ChatMsgList, chatMsgCopy)
|
||||
// 队列 保持最近50条
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) GetChatUser(accountId *string) *ChatUserRec {
|
||||
if userRec, exists := cm.privateChatUsers[*accountId]; exists {
|
||||
return userRec
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) RemoveChatUser(accountId *string) {
|
||||
delete(cm.privateChatUsers, *accountId)
|
||||
}
|
||||
|
||||
func (cm *ChatMgr) markMessagesAsRead(sender, receiver string) {
|
||||
userRec, exists := cm.privateChatUsers[receiver]
|
||||
if !exists {
|
||||
return
|
||||
}
|
||||
msgRec, exists := userRec.Users[sender]
|
||||
if !exists {
|
||||
return
|
||||
}
|
||||
msgRec.LastID = msgRec.CurrID
|
||||
}
|
@ -32,6 +32,17 @@ const (
|
||||
BlacklistStatusIsRemoved = 1 // 好友黑名单状态 已移除黑名单
|
||||
)
|
||||
|
||||
const (
|
||||
kCCBegin = iota
|
||||
kCCWorld = 1
|
||||
kCCPrivate = 2
|
||||
kCCGuild = 3
|
||||
kCCTeam = 4
|
||||
kCCBigHorn = 5
|
||||
kCCLoopMsg = 6
|
||||
kCCEnd
|
||||
)
|
||||
|
||||
// im server guild
|
||||
const (
|
||||
MaxMembers = 10
|
||||
|
@ -49,6 +49,8 @@ type MsgHandler interface {
|
||||
CMDeleteFriendShip(*f5.MsgHdr, *CMDeleteFriendShip)
|
||||
CMAddBlacklist(*f5.MsgHdr, *CMAddBlacklist)
|
||||
CMRemoveBlacklist(*f5.MsgHdr, *CMRemoveBlacklist)
|
||||
CMSetCurrPrivateChatTarget(*f5.MsgHdr, *CMSetCurrPrivateChatTarget)
|
||||
CMSendChatMsg(*f5.MsgHdr, *CMSendChatMsg)
|
||||
CMGuildInfo(*f5.MsgHdr, *CMGuildInfo)
|
||||
CMCreateGuild(*f5.MsgHdr, *CMCreateGuild)
|
||||
CMApplyToGuild(*f5.MsgHdr, *CMApplyToGuild)
|
||||
@ -104,6 +106,12 @@ func (this *MsgHandlerImpl) CMAddBlacklist(hdr *f5.MsgHdr, msg *CMAddBlacklist)
|
||||
func (this *MsgHandlerImpl) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *CMRemoveBlacklist) {
|
||||
}
|
||||
|
||||
func (this *MsgHandlerImpl) CMSetCurrPrivateChatTarget(hdr *f5.MsgHdr, msg *CMSetCurrPrivateChatTarget) {
|
||||
}
|
||||
|
||||
func (this *MsgHandlerImpl) CMSendChatMsg(hdr *f5.MsgHdr, msg *CMSendChatMsg) {
|
||||
}
|
||||
|
||||
func (this *MsgHandlerImpl) CMGuildInfo(hdr *f5.MsgHdr, msg *CMGuildInfo) {
|
||||
}
|
||||
|
||||
@ -253,6 +261,22 @@ func (this *SMRemoveBlacklist) GetNetMsgId() uint16 {
|
||||
return uint16(SMMessageIdE__SMRemoveBlacklist)
|
||||
}
|
||||
|
||||
func (this *CMSetCurrPrivateChatTarget) GetNetMsgId() uint16 {
|
||||
return uint16(CMMessageIdE__CMSetCurrPrivateChatTarget)
|
||||
}
|
||||
|
||||
func (this *CMSendChatMsg) GetNetMsgId() uint16 {
|
||||
return uint16(CMMessageIdE__CMSendChatMsg)
|
||||
}
|
||||
|
||||
func (this *SMUpdateChatRedPointNotify) GetNetMsgId() uint16 {
|
||||
return uint16(SMMessageIdE__SMUpdateChatRedPointNotify)
|
||||
}
|
||||
|
||||
func (this *SMChatMsgNotify) GetNetMsgId() uint16 {
|
||||
return uint16(SMMessageIdE__SMChatMsgNotify)
|
||||
}
|
||||
|
||||
func (this *CMGuildInfo) GetNetMsgId() uint16 {
|
||||
return uint16(CMMessageIdE__CMGuildInfo)
|
||||
}
|
||||
@ -511,6 +535,30 @@ func init() {
|
||||
},
|
||||
}
|
||||
|
||||
handlers[int(CMMessageIdE__CMSetCurrPrivateChatTarget)] = &CsNetMsgHandler{
|
||||
MsgId: int(CMMessageIdE__CMSetCurrPrivateChatTarget),
|
||||
ParseCb: func (data []byte) interface{} {
|
||||
msg := &CMSetCurrPrivateChatTarget{}
|
||||
proto.Unmarshal(data, msg)
|
||||
return msg
|
||||
},
|
||||
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||
handler.CMSetCurrPrivateChatTarget(hdr, hdr.Msg.(*CMSetCurrPrivateChatTarget))
|
||||
},
|
||||
}
|
||||
|
||||
handlers[int(CMMessageIdE__CMSendChatMsg)] = &CsNetMsgHandler{
|
||||
MsgId: int(CMMessageIdE__CMSendChatMsg),
|
||||
ParseCb: func (data []byte) interface{} {
|
||||
msg := &CMSendChatMsg{}
|
||||
proto.Unmarshal(data, msg)
|
||||
return msg
|
||||
},
|
||||
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||
handler.CMSendChatMsg(hdr, hdr.Msg.(*CMSendChatMsg))
|
||||
},
|
||||
}
|
||||
|
||||
handlers[int(CMMessageIdE__CMGuildInfo)] = &CsNetMsgHandler{
|
||||
MsgId: int(CMMessageIdE__CMGuildInfo),
|
||||
ParseCb: func (data []byte) interface{} {
|
||||
|
@ -39,6 +39,9 @@ const (
|
||||
CMMessageIdE__CMAddBlacklist CMMessageIdE = 113
|
||||
CMMessageIdE__CMRemoveBlacklist CMMessageIdE = 114
|
||||
CMMessageIdE__CMFriendInfo CMMessageIdE = 115
|
||||
// 聊天相关
|
||||
CMMessageIdE__CMSetCurrPrivateChatTarget CMMessageIdE = 200
|
||||
CMMessageIdE__CMSendChatMsg CMMessageIdE = 201
|
||||
// 公会相关
|
||||
CMMessageIdE__CMGuildInfo CMMessageIdE = 120
|
||||
CMMessageIdE__CMCreateGuild CMMessageIdE = 121
|
||||
@ -70,6 +73,8 @@ var (
|
||||
113: "_CMAddBlacklist",
|
||||
114: "_CMRemoveBlacklist",
|
||||
115: "_CMFriendInfo",
|
||||
200: "_CMSetCurrPrivateChatTarget",
|
||||
201: "_CMSendChatMsg",
|
||||
120: "_CMGuildInfo",
|
||||
121: "_CMCreateGuild",
|
||||
122: "_CMApplyToGuild",
|
||||
@ -97,6 +102,8 @@ var (
|
||||
"_CMAddBlacklist": 113,
|
||||
"_CMRemoveBlacklist": 114,
|
||||
"_CMFriendInfo": 115,
|
||||
"_CMSetCurrPrivateChatTarget": 200,
|
||||
"_CMSendChatMsg": 201,
|
||||
"_CMGuildInfo": 120,
|
||||
"_CMCreateGuild": 121,
|
||||
"_CMApplyToGuild": 122,
|
||||
@ -178,6 +185,9 @@ const (
|
||||
SMMessageIdE__SMDemoteMember SMMessageIdE = 128
|
||||
SMMessageIdE__SMDisband SMMessageIdE = 129
|
||||
SMMessageIdE__SMSearchGuilds SMMessageIdE = 130
|
||||
// 聊天相关
|
||||
SMMessageIdE__SMUpdateChatRedPointNotify SMMessageIdE = 200
|
||||
SMMessageIdE__SMChatMsgNotify SMMessageIdE = 201
|
||||
)
|
||||
|
||||
// Enum value maps for SMMessageIdE.
|
||||
@ -209,6 +219,8 @@ var (
|
||||
128: "_SMDemoteMember",
|
||||
129: "_SMDisband",
|
||||
130: "_SMSearchGuilds",
|
||||
200: "_SMUpdateChatRedPointNotify",
|
||||
201: "_SMChatMsgNotify",
|
||||
}
|
||||
SMMessageIdE_value = map[string]int32{
|
||||
"_SMPing": 101,
|
||||
@ -237,6 +249,8 @@ var (
|
||||
"_SMDemoteMember": 128,
|
||||
"_SMDisband": 129,
|
||||
"_SMSearchGuilds": 130,
|
||||
"_SMUpdateChatRedPointNotify": 200,
|
||||
"_SMChatMsgNotify": 201,
|
||||
}
|
||||
)
|
||||
|
||||
@ -281,7 +295,7 @@ var File_cs_msgid_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_cs_msgid_proto_rawDesc = []byte{
|
||||
0x0a, 0x0e, 0x63, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x02, 0x63, 0x73, 0x2a, 0xa1, 0x04, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||
0x12, 0x02, 0x63, 0x73, 0x2a, 0xd8, 0x04, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||
0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x43, 0x4d, 0x50, 0x69, 0x6e,
|
||||
0x67, 0x10, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x43, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10,
|
||||
0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
|
||||
@ -302,55 +316,62 @@ var file_cs_msgid_proto_rawDesc = []byte{
|
||||
0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x71, 0x12, 0x16, 0x0a, 0x12, 0x5f, 0x43, 0x4d, 0x52, 0x65,
|
||||
0x6d, 0x6f, 0x76, 0x65, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x72, 0x12,
|
||||
0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x66, 0x6f,
|
||||
0x10, 0x73, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e,
|
||||
0x66, 0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x43, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74,
|
||||
0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x41,
|
||||
0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a,
|
||||
0x0a, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a,
|
||||
0x09, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d,
|
||||
0x5f, 0x43, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12,
|
||||
0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d,
|
||||
0x62, 0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x50, 0x72, 0x6f, 0x6d,
|
||||
0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f,
|
||||
0x43, 0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80,
|
||||
0x01, 0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10,
|
||||
0x81, 0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47,
|
||||
0x75, 0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x2a, 0xb2, 0x04, 0x0a, 0x0d, 0x53, 0x4d, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53,
|
||||
0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70,
|
||||
0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x66, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c,
|
||||
0x6f, 0x67, 0x69, 0x6e, 0x10, 0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63,
|
||||
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x68, 0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x4d, 0x53,
|
||||
0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x49, 0x64, 0x10, 0x69, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61,
|
||||
0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x10, 0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d,
|
||||
0x41, 0x64, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46,
|
||||
0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a,
|
||||
0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
||||
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53,
|
||||
0x4d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65,
|
||||
0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f,
|
||||
0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17,
|
||||
0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
||||
0x64, 0x53, 0x68, 0x69, 0x70, 0x10, 0x70, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x64,
|
||||
0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x71, 0x12, 0x16, 0x0a, 0x12,
|
||||
0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x10, 0x72, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
||||
0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x73, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x47, 0x75,
|
||||
0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x53, 0x4d,
|
||||
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a,
|
||||
0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64,
|
||||
0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65,
|
||||
0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10,
|
||||
0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69,
|
||||
0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69,
|
||||
0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53,
|
||||
0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f,
|
||||
0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d,
|
||||
0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73,
|
||||
0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x53, 0x65,
|
||||
0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x42, 0x06, 0x5a,
|
||||
0x10, 0x73, 0x12, 0x20, 0x0a, 0x1b, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72,
|
||||
0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65,
|
||||
0x74, 0x10, 0xc8, 0x01, 0x12, 0x13, 0x0a, 0x0e, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x6e, 0x64, 0x43,
|
||||
0x68, 0x61, 0x74, 0x4d, 0x73, 0x67, 0x10, 0xc9, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d,
|
||||
0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f,
|
||||
0x43, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12,
|
||||
0x13, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69,
|
||||
0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f,
|
||||
0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47,
|
||||
0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73,
|
||||
0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10,
|
||||
0x5f, 0x43, 0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
|
||||
0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d,
|
||||
0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x44,
|
||||
0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d,
|
||||
0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x2a,
|
||||
0xeb, 0x04, 0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x5f,
|
||||
0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65, 0x12, 0x0f,
|
||||
0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x66, 0x12,
|
||||
0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10, 0x67, 0x12, 0x10, 0x0a,
|
||||
0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x68, 0x12,
|
||||
0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72,
|
||||
0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x10, 0x69, 0x12, 0x11, 0x0a,
|
||||
0x0d, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x10, 0x6a,
|
||||
0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d,
|
||||
0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10,
|
||||
0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x6e, 0x64,
|
||||
0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69,
|
||||
0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x44, 0x65, 0x6c, 0x65,
|
||||
0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68, 0x69, 0x70, 0x10, 0x70, 0x12, 0x13,
|
||||
0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73,
|
||||
0x74, 0x10, 0x71, 0x12, 0x16, 0x0a, 0x12, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
|
||||
0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x72, 0x12, 0x11, 0x0a, 0x0d, 0x5f,
|
||||
0x53, 0x4d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x73, 0x12, 0x10,
|
||||
0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x78,
|
||||
0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x53, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75, 0x69,
|
||||
0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79,
|
||||
0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x53, 0x4d,
|
||||
0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x53, 0x4d,
|
||||
0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c,
|
||||
0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10, 0x5f,
|
||||
0x53, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10,
|
||||
0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x4d,
|
||||
0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x44, 0x65,
|
||||
0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f, 0x0a,
|
||||
0x0a, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12, 0x14,
|
||||
0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64,
|
||||
0x73, 0x10, 0x82, 0x01, 0x12, 0x20, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x55, 0x70, 0x64, 0x61, 0x74,
|
||||
0x65, 0x43, 0x68, 0x61, 0x74, 0x52, 0x65, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4e, 0x6f, 0x74,
|
||||
0x69, 0x66, 0x79, 0x10, 0xc8, 0x01, 0x12, 0x15, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x43, 0x68, 0x61,
|
||||
0x74, 0x4d, 0x73, 0x67, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xc9, 0x01, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x3b, 0x63, 0x73,
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,3 +9,4 @@ var friendMgr = new(FriendsMgr)
|
||||
|
||||
// var guildMgr = new(GuildMgr)
|
||||
var guildMgr = NewGuildMgr()
|
||||
var chatMgr = NewChatMgr(playerMgr, friendMgr, guildMgr)
|
||||
|
@ -355,6 +355,29 @@ func PrintUsers(str string, userList []*User) {
|
||||
}
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) IsFriendShip(account1Id, Account2Id string) bool {
|
||||
var found bool
|
||||
for _, friendship := range fm.friendships[account1Id] {
|
||||
if friendship.User1.AccountId == Account2Id || friendship.User2.AccountId == Account2Id {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) GetFriendByAccountId(account1Id, Account2Id string) *User {
|
||||
for _, friendship := range fm.friendships[account1Id] {
|
||||
if friendship.User1.AccountId == Account2Id {
|
||||
return friendship.User1
|
||||
}
|
||||
|
||||
if friendship.User2.AccountId == Account2Id {
|
||||
return friendship.User2
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) findFriendShipIndex(Account1Id, Account2Id string) int {
|
||||
// 通常 account1Id,指自己, account2Id 指对方
|
||||
if _, exists := fm.friendships[Account1Id]; exists {
|
||||
|
@ -80,3 +80,7 @@ func (g *Guild) RemoveMember(accountId string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Guild) GetGuildId() int64 {
|
||||
return g.GuildId
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ func (gm *GuildMgr) loadGuildLogsFromDB() {
|
||||
}
|
||||
func (gm *GuildMgr) loadGuildLogsFromDBResult(err error, pagination *f5.Pagination) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
//panic(err)
|
||||
return
|
||||
}
|
||||
//total := pagination.Total
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"q5"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -51,9 +50,9 @@ func (gm *GuildMgr) loadFromDB() {
|
||||
//// 加载公会日志
|
||||
gm.loadGuildLogsFromDB()
|
||||
|
||||
for gm.loadedFlags != 0 {
|
||||
time.Sleep(time.Millisecond * 1000)
|
||||
}
|
||||
//for gm.loadedFlags != 0 {
|
||||
// time.Sleep(time.Millisecond * 1000)
|
||||
//}
|
||||
}
|
||||
|
||||
// CreateGuild 创建公会
|
||||
@ -504,6 +503,14 @@ func (gm *GuildMgr) checkJoinGuild(accountId string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (gm *GuildMgr) GetGuildIdByAccountId(accountId string) int64 {
|
||||
guild := gm.GetGuildByAccountId(accountId)
|
||||
if guild != nil {
|
||||
return guild.GuildId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func containsSubstring(s, substr string) bool {
|
||||
return len(s) >= len(substr) && s[len(s)-len(substr):] == substr
|
||||
}
|
||||
|
@ -3,14 +3,24 @@ package main
|
||||
import (
|
||||
"cs"
|
||||
"f5"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
"q5"
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
cs.MsgHandlerImpl
|
||||
socket f5.WspCliConn
|
||||
accountId string
|
||||
sessionId string
|
||||
socket f5.WspCliConn
|
||||
accountId string
|
||||
sessionId string
|
||||
chatChannel int
|
||||
privateTargetAccountId string // 私聊对象 accountId
|
||||
worldChannelLastId uint64 // 世界聊天 last id
|
||||
guildChannelLastId uint64 // 公会聊天 last id
|
||||
privateChatLastId uint64 // 私聊 last id
|
||||
}
|
||||
|
||||
func (p *Player) GetAccountId() string {
|
||||
return p.accountId
|
||||
}
|
||||
|
||||
// CMSearchUser 搜索用户
|
||||
@ -225,6 +235,61 @@ func (p *Player) CMFriendInfo(hdr *f5.MsgHdr, msg *cs.CMFriendInfo) {
|
||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
}
|
||||
|
||||
// CMSendChatMsg 发送聊天消息
|
||||
func (p *Player) CMSendChatMsg(hdr *f5.MsgHdr, msg *cs.CMSendChatMsg) {
|
||||
chatChannel := *msg.ChatChannel
|
||||
if !IsValidChatChannel(chatChannel) {
|
||||
return
|
||||
}
|
||||
switch chatChannel {
|
||||
case kCCWorld:
|
||||
chatMgr.ProcWorldChat(p, msg)
|
||||
case kCCPrivate:
|
||||
chatMgr.ProcPrivateChat(p, msg)
|
||||
case kCCGuild:
|
||||
chatMgr.ProcGuildChat(p, msg)
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Player) SyncPrivateChatRedPoint() {
|
||||
//rspMsg := &cs.SMDeleteFriendShip{}
|
||||
msg := &cs.SMUpdatePrivateChatRedPointNotify{}
|
||||
chatMgr.FillSMUpdatePrivateChatRedPointNotify(p, msg)
|
||||
}
|
||||
|
||||
// CMReadMsgAndOpenChatNotify 读取聊天消息列表并且开启聊天通知
|
||||
func (p *Player) CMReadMsgAndOpenChatNotify(hdr *f5.MsgHdr, msg *cs.CMReadMsgAndOpenChatNotify) {
|
||||
chatChannel := *msg.CurrChannel
|
||||
if !IsValidChatChannel(chatChannel) {
|
||||
return
|
||||
}
|
||||
if chatChannel == kCCPrivate {
|
||||
p.SyncPrivateChatRedPoint()
|
||||
}
|
||||
}
|
||||
|
||||
// CMSetCurrPrivateChatTarget 设置当前私聊目标
|
||||
func (p *Player) CMSetCurrPrivateChatTarget(hdr *f5.MsgHdr, msg *cs.CMSetCurrPrivateChatTarget) {
|
||||
p.privateTargetAccountId = msg.GetTargetAccountId()
|
||||
chatMgr.SyncPrivateChatMsg(p)
|
||||
}
|
||||
|
||||
func (p *Player) MarkNewMsg() {
|
||||
rspMsg := &cs.SMUpdateChatRedPointNotify{}
|
||||
chatMgr.FillSMUpdateChatRedPointNotify(p, rspMsg)
|
||||
p.SendMsg(rspMsg)
|
||||
}
|
||||
|
||||
func (p *Player) SendMsg(rspMsg proto.Message) {
|
||||
wspListener.sendProxyMsg(p.socket.Conn, p.socket.SocketHandle, rspMsg)
|
||||
}
|
||||
|
||||
func IsValidChatChannel(chatChannel int32) bool {
|
||||
return chatChannel > kCCBegin && chatChannel < kCCEnd
|
||||
}
|
||||
|
||||
// CMGuildInfo 我的公会信息
|
||||
func (p *Player) CMGuildInfo(hdr *f5.MsgHdr, msg *cs.CMGuildInfo) {
|
||||
rspMsg := new(cs.SMGuildInfo)
|
||||
@ -423,3 +488,8 @@ func (p *Player) FillGuild(guilds []Guild) []*cs.MFGuild {
|
||||
}
|
||||
return resGuilds
|
||||
}
|
||||
|
||||
func (p *Player) IncrPrivateChatLastId() uint64 {
|
||||
p.privateChatLastId++
|
||||
return p.privateChatLastId
|
||||
}
|
||||
|
@ -143,6 +143,10 @@ func (this *PlayerMgr) reportServerState(masterIp string, masterPort int32) {
|
||||
})
|
||||
}
|
||||
|
||||
func (this *PlayerMgr) GetPlayers() map[string]*Player {
|
||||
return this.accountIdHash
|
||||
}
|
||||
|
||||
func (this *PlayerMgr) addPlayer(p *Player) {
|
||||
this.accountIdHash[p.accountId] = p
|
||||
}
|
||||
|
@ -22,6 +22,11 @@ enum CMMessageId_e
|
||||
_CMRemoveBlacklist = 114;
|
||||
_CMFriendInfo = 115;
|
||||
|
||||
// 聊天相关
|
||||
_CMSetCurrPrivateChatTarget = 200;
|
||||
_CMSendChatMsg = 201;
|
||||
|
||||
|
||||
// 公会相关
|
||||
_CMGuildInfo = 120;
|
||||
_CMCreateGuild = 121;
|
||||
@ -67,4 +72,8 @@ enum SMMessageId_e
|
||||
_SMDemoteMember = 128;
|
||||
_SMDisband = 129;
|
||||
_SMSearchGuilds = 130;
|
||||
|
||||
// 聊天相关
|
||||
_SMUpdateChatRedPointNotify = 200;
|
||||
_SMChatMsgNotify = 201;
|
||||
}
|
||||
|
@ -263,6 +263,82 @@ message MFUser {
|
||||
optional string username = 2;
|
||||
}
|
||||
|
||||
// --- 聊天 ---
|
||||
// 发送聊天消息
|
||||
message CMSendChatMsg
|
||||
{
|
||||
optional int32 chat_channel = 1; //聊天频道 1: 世界 2:好友 3:战队 4:小队(这时target表示队伍Id) 5:大喇叭 6:跑马灯(只能收不能发)
|
||||
optional string targetAccountId = 2; //目标
|
||||
optional int32 msg_type = 3; ////消息类型 0:文本消息(json) 1:自定义协议 (json) 2:纯文本(但是任会做屏蔽字替换)
|
||||
optional string msg_body = 4; //消息内容
|
||||
repeated string members = 5; //小队成员列表(包含自己)
|
||||
}
|
||||
|
||||
//读取聊天消息列表并且开启聊天通知
|
||||
message CMReadMsgAndOpenChatNotify
|
||||
{
|
||||
optional int32 curr_channel = 1; //当前频道
|
||||
repeated MFPair64 last_ids = 2; //所有频道 key:聊天频道 val:该频道最后一次收到的消息id
|
||||
}
|
||||
|
||||
//设置当前私聊目标
|
||||
message CMSetCurrPrivateChatTarget
|
||||
{
|
||||
optional string target_account_id = 1; //私聊对象id, 只有当前聊频道是私聊时字段才有意义
|
||||
optional int64 last_id = 2; //最后收到想消息id
|
||||
}
|
||||
|
||||
//关闭聊天通知
|
||||
message CMCloseChatNotify
|
||||
{
|
||||
}
|
||||
|
||||
//更新聊天红点信息
|
||||
message SMUpdateChatRedPointNotify
|
||||
{
|
||||
repeated int32 has_unread_msg_channels = 1; //含有未读消息的渠道id列表,不在列表里的渠道默认不含有
|
||||
}
|
||||
|
||||
message SMChatMsgNotify
|
||||
{
|
||||
repeated MFChatMsg msg_list = 1; //消息列表,客户端需要根据chat_channel和msg_uuid更新本地的last_ids
|
||||
}
|
||||
|
||||
//更新红点信息
|
||||
message SMUpdateRedPointNotify
|
||||
{
|
||||
optional int32 red_point_flags = 1; //红点信息 1<<0:好友申请 1<<1:公会申请 1<<2:聊天红点
|
||||
}
|
||||
|
||||
//更新私聊红点信息
|
||||
message SMUpdatePrivateChatRedPointNotify
|
||||
{
|
||||
repeated string has_unread_msg_accounts = 1; //有未读消息的账号列表,不在列表里的好友more不含有
|
||||
}
|
||||
|
||||
//更新频道最后一次收到的消息id
|
||||
message SMUpdateChatChannelLastId
|
||||
{
|
||||
repeated MFPair64 last_ids = 1; //所有频道 key:聊天频道 val:该频道最后一次收到的消息id
|
||||
}
|
||||
|
||||
//聊天消息
|
||||
message MFChatMsg
|
||||
{
|
||||
/*
|
||||
消息唯一id,递增序列,客户端可以用chat_channel + msg_uuid作为主键
|
||||
!!!不同的频道msg_uuid可能重复
|
||||
*/
|
||||
optional uint64 msg_uuid = 1;
|
||||
optional string sender = 2; //发送者
|
||||
optional string receiver = 3; //接收者
|
||||
optional int32 chat_channel = 4; //聊天频道
|
||||
optional int32 msg_type = 5; //消息类型 0:文本消息(json) 1:自定义协议 (json) 2:纯文本(但是任会做屏蔽字替换)
|
||||
optional string msg_body = 6; //消息内容(json类型里的字段!开头的会做屏蔽替换)
|
||||
optional int64 send_time = 7; //消息发送时间
|
||||
}
|
||||
|
||||
// --- 公会 ---
|
||||
// 请求公会信息
|
||||
message CMGuildInfo
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user