diff --git a/server/imserver_new/friend/friendmgr.go b/server/imserver_new/friend/friendmgr.go index 1c81a987..fe46e030 100644 --- a/server/imserver_new/friend/friendmgr.go +++ b/server/imserver_new/friend/friendmgr.go @@ -31,11 +31,7 @@ func (this *FriendMgr) IsFriend(accountId1 string, accountId2 string) bool { } func (this *FriendMgr) HasFriend(accountId string) bool { - myFriends := this.getFriends(accountId) - if myFriends != nil { - return len(*myFriends) > 0 - } - return false + return this.GetFriendNum(accountId) > 0 } func (this *FriendMgr) GetFriendNum(accountId string) int32 { @@ -46,6 +42,17 @@ func (this *FriendMgr) GetFriendNum(accountId string) int32 { return 0 } +func (this *FriendMgr) TraverseFriend(accountId string, cb func(string, int32) bool) { + myFriends := this.getFriends(accountId) + if myFriends != nil { + for a, t := range *myFriends { + if !cb(a, t) { + break + } + } + } +} + func (this *FriendMgr) getFriends(accountId string) *map[string]int32 { if friends, ok := this.friendHash[accountId]; ok { return friends