From 1c0eff8711009f249c574f359a2d21c9781fce14 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 23 Mar 2024 15:34:27 +0800 Subject: [PATCH] 1 --- server/imserver_new/cache/cachemgr.go | 14 ++++---- server/imserver_new/cache/export.go | 12 +++++++ server/imserver_new/chat/chatmgr.go | 10 +++--- server/imserver_new/chat/export.go | 12 +++++++ server/imserver_new/constant/constant.go | 4 +++ server/imserver_new/friend/export.go | 12 +++++++ server/imserver_new/friend/friendmgr.go | 36 ++++++++++---------- server/imserver_new/global/global.go | 16 +++++++++ server/imserver_new/guild/export.go | 12 +++++++ server/imserver_new/guild/guildmgr.go | 42 ++++++++++++------------ 10 files changed, 119 insertions(+), 51 deletions(-) create mode 100644 server/imserver_new/cache/export.go create mode 100644 server/imserver_new/chat/export.go create mode 100644 server/imserver_new/friend/export.go create mode 100644 server/imserver_new/guild/export.go diff --git a/server/imserver_new/cache/cachemgr.go b/server/imserver_new/cache/cachemgr.go index 0003e6fe..d75f5482 100644 --- a/server/imserver_new/cache/cachemgr.go +++ b/server/imserver_new/cache/cachemgr.go @@ -5,33 +5,33 @@ import ( "main/common" ) -type CacheMgr struct { +type cacheMgr struct { lock sync.Mutex userHash map[string]*userProfile } -func (this *CacheMgr) init() { +func (this *cacheMgr) Init() { this.userHash = make(map[string]*userProfile) } -func (this *CacheMgr) UnInit() { +func (this *cacheMgr) UnInit() { } -func (this *CacheMgr) AsyncGetUsers(accountIds []string, cb func(int32, string)) { +func (this *cacheMgr) AsyncGetUsers(accountIds []string, cb func(int32, string)) { } -func (this *CacheMgr) GetUserProfile(accountId string) common.UserProfile { +func (this *cacheMgr) GetUserProfile(accountId string) common.UserProfile { if user, ok := this.userHash[accountId]; ok { return user } return nil } -func (this *CacheMgr) PreLoad(accountIds []string) { +func (this *cacheMgr) PreLoad(accountIds []string) { } -func (this *CacheMgr) AsyncSearch(sinceId int64, q string, +func (this *cacheMgr) AsyncSearch(sinceId int64, q string, cb func(int32, string, int64, []string)) { } diff --git a/server/imserver_new/cache/export.go b/server/imserver_new/cache/export.go new file mode 100644 index 00000000..273ccdba --- /dev/null +++ b/server/imserver_new/cache/export.go @@ -0,0 +1,12 @@ +package cache + +import ( + "main/constant" + "main/global" +) + +var _cacheMgr = new(cacheMgr) + +func init() { + global.RegModule(constant.CACHE_MGR_MODULE_IDX, _cacheMgr) +} diff --git a/server/imserver_new/chat/chatmgr.go b/server/imserver_new/chat/chatmgr.go index de38b2c0..3ac60787 100644 --- a/server/imserver_new/chat/chatmgr.go +++ b/server/imserver_new/chat/chatmgr.go @@ -3,17 +3,17 @@ package chat import ( ) -type ChatMgr struct { +type chatMgr struct { } -func NewChatMgr() *ChatMgr { - return new(ChatMgr) +func NewChatMgr() *chatMgr { + return new(chatMgr) } -func (this *ChatMgr) Init() { +func (this *chatMgr) Init() { } -func (this *ChatMgr) UnInit() { +func (this *chatMgr) UnInit() { } diff --git a/server/imserver_new/chat/export.go b/server/imserver_new/chat/export.go new file mode 100644 index 00000000..70b55c2e --- /dev/null +++ b/server/imserver_new/chat/export.go @@ -0,0 +1,12 @@ +package chat + +import ( + "main/constant" + "main/global" +) + +var _chatMgr = new(chatMgr) + +func init() { + global.RegModule(constant.CHAT_MGR_MODULE_IDX, _chatMgr) +} diff --git a/server/imserver_new/constant/constant.go b/server/imserver_new/constant/constant.go index 1658d156..2d3b1f1f 100644 --- a/server/imserver_new/constant/constant.go +++ b/server/imserver_new/constant/constant.go @@ -9,6 +9,10 @@ const ( WSPLISTENER_MODULE_IDX HANDLER_MGR_MODULE_IDX PLAYER_MGR_MODULE_IDX + FRIEND_MGR_MODULE_IDX + GUILD_MGR_MODULE_IDX + CHAT_MGR_MODULE_IDX + CACHE_MGR_MODULE_IDX MAX_MODULE_IDX ) diff --git a/server/imserver_new/friend/export.go b/server/imserver_new/friend/export.go new file mode 100644 index 00000000..afbbc46f --- /dev/null +++ b/server/imserver_new/friend/export.go @@ -0,0 +1,12 @@ +package friend + +import ( + "main/constant" + "main/global" +) + +var _friendMgr = new(friendMgr) + +func init() { + global.RegModule(constant.FRIEND_MGR_MODULE_IDX, _friendMgr) +} diff --git a/server/imserver_new/friend/friendmgr.go b/server/imserver_new/friend/friendmgr.go index a23e6aa2..310ce600 100644 --- a/server/imserver_new/friend/friendmgr.go +++ b/server/imserver_new/friend/friendmgr.go @@ -4,27 +4,27 @@ import ( "q5" ) -type FriendMgr struct { +type friendMgr struct { friendHash map[string]*map[string]int32 blackHash map[string]*map[string]int32 byBlackHash map[string]*map[string]int32 } -func (this *FriendMgr) Init() { +func (this *friendMgr) Init() { this.friendHash = make(map[string]*map[string]int32) this.blackHash = make(map[string]*map[string]int32) this.byBlackHash = make(map[string]*map[string]int32) } -func (this *FriendMgr) UnInit() { +func (this *friendMgr) UnInit() { } -func (this *FriendMgr) loadFromDB() { +func (this *friendMgr) loadFromDB() { //this.loadFriendships() //this.loadBlacklist() } -func (this *FriendMgr) IsFriend(accountId1 string, accountId2 string) bool { +func (this *friendMgr) IsFriend(accountId1 string, accountId2 string) bool { myFriends := this.getFriends(accountId1) if myFriends != nil { if _, ok := (*myFriends)[accountId2]; ok { @@ -34,11 +34,11 @@ func (this *FriendMgr) IsFriend(accountId1 string, accountId2 string) bool { return false } -func (this *FriendMgr) HasFriend(accountId string) bool { +func (this *friendMgr) HasFriend(accountId string) bool { return this.GetFriendNum(accountId) > 0 } -func (this *FriendMgr) GetFriendNum(accountId string) int32 { +func (this *friendMgr) GetFriendNum(accountId string) int32 { myFriends := this.getFriends(accountId) if myFriends != nil { return int32(len(*myFriends)) @@ -46,7 +46,7 @@ func (this *FriendMgr) GetFriendNum(accountId string) int32 { return 0 } -func (this *FriendMgr) TraverseFriend(accountId string, cb func(string, int32) bool) { +func (this *friendMgr) TraverseFriend(accountId string, cb func(string, int32) bool) { myFriends := this.getFriends(accountId) if myFriends != nil { for a, t := range *myFriends { @@ -57,7 +57,7 @@ func (this *FriendMgr) TraverseFriend(accountId string, cb func(string, int32) b } } -func (this *FriendMgr) GetFriendList(accountId string) []string { +func (this *friendMgr) GetFriendList(accountId string) []string { friendList := []string{} this.TraverseFriend( accountId, @@ -69,7 +69,7 @@ func (this *FriendMgr) GetFriendList(accountId string) []string { return friendList } -func (this *FriendMgr) GetBlackList(accountId string) []string { +func (this *friendMgr) GetBlackList(accountId string) []string { blackList := []string{} /* this.TraverseFriend( @@ -83,37 +83,37 @@ func (this *FriendMgr) GetBlackList(accountId string) []string { return blackList } -func (this *FriendMgr) getFriends(accountId string) *map[string]int32 { +func (this *friendMgr) getFriends(accountId string) *map[string]int32 { if friends, ok := this.friendHash[accountId]; ok { return friends } return nil } -func (this *FriendMgr) AsyncGetApplyList(int64, string, func(int32, string, int64, []string)) { +func (this *friendMgr) AsyncGetApplyList(int64, string, func(int32, string, int64, []string)) { } -func (this *FriendMgr) AsyncAddFriend(senderId string, targetId string, cb func(int32, string)) { +func (this *friendMgr) AsyncAddFriend(senderId string, targetId string, cb func(int32, string)) { } -func (this *FriendMgr) AsyncAccpetApply(senderId string, targetId string, cb func(int32, string)) { +func (this *friendMgr) AsyncAccpetApply(senderId string, targetId string, cb func(int32, string)) { } -func (this *FriendMgr) AsyncRejectApply(senderId string, targetId string, cb func(int32, string)) { +func (this *friendMgr) AsyncRejectApply(senderId string, targetId string, cb func(int32, string)) { } -func (this *FriendMgr) AsynDeleteFriend(senderId string, targetId string, cb func(int32, string)) { +func (this *friendMgr) AsynDeleteFriend(senderId string, targetId string, cb func(int32, string)) { } -func (this *FriendMgr) AsyncAddBlack(senderId string, targetId string, cb func(int32, string)) { +func (this *friendMgr) AsyncAddBlack(senderId string, targetId string, cb func(int32, string)) { } -func (this *FriendMgr) AsyncRemoveBlack(senderId string, targetId string, cb func(int32, string)) { +func (this *friendMgr) AsyncRemoveBlack(senderId string, targetId string, cb func(int32, string)) { } diff --git a/server/imserver_new/global/global.go b/server/imserver_new/global/global.go index a4bfee0c..cedbe406 100644 --- a/server/imserver_new/global/global.go +++ b/server/imserver_new/global/global.go @@ -70,6 +70,22 @@ func RegModule(idx int32, m q5.Module) { { playerMgr = m.(common.PlayerMgr) } + case constant.FRIEND_MGR_MODULE_IDX: + { + friendMgr = m.(common.FriendMgr) + } + case constant.GUILD_MGR_MODULE_IDX: + { + guildMgr = m.(common.GuildMgr) + } + case constant.CHAT_MGR_MODULE_IDX: + { + chatMgr = m.(common.ChatMgr) + } + case constant.CACHE_MGR_MODULE_IDX: + { + cacheMgr = m.(common.CacheMgr) + } default: { panic("unknow module") diff --git a/server/imserver_new/guild/export.go b/server/imserver_new/guild/export.go new file mode 100644 index 00000000..fb39bd06 --- /dev/null +++ b/server/imserver_new/guild/export.go @@ -0,0 +1,12 @@ +package guild + +import ( + "main/constant" + "main/global" +) + +var _guildMgr = new(guildMgr) + +func init() { + global.RegModule(constant.GUILD_MGR_MODULE_IDX, _guildMgr) +} diff --git a/server/imserver_new/guild/guildmgr.go b/server/imserver_new/guild/guildmgr.go index b4a882da..a6ef875e 100644 --- a/server/imserver_new/guild/guildmgr.go +++ b/server/imserver_new/guild/guildmgr.go @@ -11,88 +11,88 @@ const ( LoadGuildLogFlag ) -type GuildMgr struct { +type guildMgr struct { guilds map[int64]*Guild // 公会ID -> 公会 guildLogs map[int64][]*GuildLog // 公会ID -> []公会日志列表 userGuilds map[string]int64 // accountId -> 公会ID loadedFlags int64 } -func (this *GuildMgr) Init() { +func (this *guildMgr) Init() { } -func (this *GuildMgr) UnInit() { +func (this *guildMgr) UnInit() { } -func (this *GuildMgr) isNameTooLong(name string, maxNum int) bool { +func (this *guildMgr) isNameTooLong(name string, maxNum int) bool { return len(name) > maxNum } -func (this *GuildMgr) GetGuildByAccountId(string) common.Guild { +func (this *guildMgr) GetGuildByAccountId(string) common.Guild { return nil } -func (this *GuildMgr) GetRecommendGuilds(string) []Guild { +func (this *guildMgr) GetRecommendGuilds(string) []Guild { guilds := []Guild{} return guilds } -func (this *GuildMgr) GetGuildRank() []Guild { +func (this *guildMgr) GetGuildRank() []Guild { guilds := []Guild{} return guilds } -func (this *GuildMgr) AsyncCreateGuild(string, string, func(int32, string, int64)) { +func (this *guildMgr) AsyncCreateGuild(string, string, func(int32, string, int64)) { } -func (this *GuildMgr) AsyncGetApplyList(int64, string, func(int32, string, int64, []string)) { +func (this *guildMgr) AsyncGetApplyList(int64, string, func(int32, string, int64, []string)) { } -func (this *GuildMgr) AsyncApplyJoin(string, string, func(int32, string)) { +func (this *guildMgr) AsyncApplyJoin(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncAcceptApply(string, string, func(int32, string)) { +func (this *guildMgr) AsyncAcceptApply(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncRejectApply(string, string, func(int32, string)) { +func (this *guildMgr) AsyncRejectApply(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncLeave(string, string, func(int32, string)) { +func (this *guildMgr) AsyncLeave(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncKickout(string, string, func(int32, string)) { +func (this *guildMgr) AsyncKickout(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncDisband(string, string, func(int32, string)) { +func (this *guildMgr) AsyncDisband(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncSetNotice(string, string, func(int32, string)) { +func (this *guildMgr) AsyncSetNotice(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncSetAvatar(string, string, func(int32, string)) { +func (this *guildMgr) AsyncSetAvatar(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncSetName(string, string, func(int32, string)) { +func (this *guildMgr) AsyncSetName(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncSetJoinCond(string, string, func(int32, string)) { +func (this *guildMgr) AsyncSetJoinCond(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncSearch(string, string, func(int32, string)) { +func (this *guildMgr) AsyncSearch(string, string, func(int32, string)) { } -func (this *GuildMgr) AsyncGetGuildLogs(string, string, func(int32, string)) { +func (this *guildMgr) AsyncGetGuildLogs(string, string, func(int32, string)) { }