From 347f9e4458db917a39f8bdda0c9389bc95031075 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 22 Mar 2024 17:33:36 +0800 Subject: [PATCH] 1 --- server/imserver_new/common/types.go | 26 -------- server/imserver_new/friend/friends.go | 92 --------------------------- 2 files changed, 118 deletions(-) delete mode 100644 server/imserver_new/friend/friends.go diff --git a/server/imserver_new/common/types.go b/server/imserver_new/common/types.go index c106d731..85849bb5 100644 --- a/server/imserver_new/common/types.go +++ b/server/imserver_new/common/types.go @@ -51,38 +51,14 @@ type PlayerMgr interface { ProcessCMMsg(*cs.CsNetMsgHandler, *f5.MsgHdr) GetPlayerBySocket(f5.WspCliConn) Player GetPlayerByAccountId(string) Player - GetOnlineStatus(string) int32 OnSocketClose(f5.WspCliConn) - 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 { - GetFriendships() map[string]Friendship - GetFriendBlackList() map[string]FriendBlackList } type FriendMgr interface { - GetFriendByAccountId(account1Id, account2Id string) User - AddUser(string, User) - GetUser(string) User - LoadUserFriendships(user User, where [][]string) } type Guild interface { GetGuildId() int64 - GetMembers() map[string]GuildMember } type GuildMember interface { @@ -91,8 +67,6 @@ type GuildMember interface { type GuildMgr interface { GetGuildByAccountId(string) Guild - GetGuildIdByAccountId(string) int64 - RandomGuilds() []*Guild } type CacheMgr interface { diff --git a/server/imserver_new/friend/friends.go b/server/imserver_new/friend/friends.go deleted file mode 100644 index 52bb9955..00000000 --- a/server/imserver_new/friend/friends.go +++ /dev/null @@ -1,92 +0,0 @@ -package friend - -import ( - "main/constant" - "main/common" -) - -type User struct { - AccountId string - FriendBlackList map[string]*FriendBlackList // BlockedAccountId -> FriendBlackList - Friendships map[string]*Friendship // FriendAccountId -> Friendship -} - -type Friendship struct { - FriendAccountId string // friend's account id - IsFriendship int32 // 0 pending, 1 ok, 2 reject, 3 disband - RequestTime int64 // send time -} - -// FriendBlackList 直接存列表, 黑名单上限50个 -type FriendBlackList struct { - AccountId string - IsRemoved int32 // default: 0, isRemoved -} - -func NewUser(accountId string) *User { - user := &User{ - AccountId: accountId, - //FriendRequest: make(map[string]*FriendRequest), - FriendBlackList: make(map[string]*FriendBlackList), - Friendships: make(map[string]*Friendship, constant.MaxFriendMembers), - } - 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) { - friendShip := &Friendship{ - FriendAccountId: account2Id, - IsFriendship: IsFriendship, - RequestTime: requestTime, - } - u.Friendships[account2Id] = friendShip -} - -func (u *User) RemoveFriendRequest(account2Id string) { - delete(u.Friendships, account2Id) -} - -func (u *User) RemoveFriendShip(account2Id string) { - delete(u.Friendships, account2Id) -} - -func (u *User) IsInReq(FriendAccountId string) bool { - friendRequest, exists := u.Friendships[FriendAccountId] - return exists && friendRequest.IsFriendship == 0 -} - -// AddBlacklist 加入黑名单 -func (u *User) AddBlacklist(b *FriendBlackList) { - u.FriendBlackList[b.AccountId] = b -} - -// GetBlacklist 获取黑名单 -func (u *User) GetBlacklist(account2Id string) *FriendBlackList { - if friendBlackList, exists := u.FriendBlackList[account2Id]; exists { - return friendBlackList - } - return nil -} - -// IsInBlacklist 在黑名单中 -func (u *User) IsInBlacklist(account2Id string) bool { - friendBlackList, exists := u.FriendBlackList[account2Id] - return exists && friendBlackList.IsRemoved == 0 -} - -func (u *User) RemoveBlacklist(account2Id string) { - delete(u.FriendBlackList, account2Id) -} - -// GetBlacklistCount 获取黑名单 -func (u *User) GetBlacklistCount() int { - return len(u.FriendBlackList) -}