diff --git a/server/imserver_new/common/types.go b/server/imserver_new/common/types.go index f81e650a..90e37a40 100644 --- a/server/imserver_new/common/types.go +++ b/server/imserver_new/common/types.go @@ -59,6 +59,12 @@ type FriendMgr interface { GetFriendList(string) []string GetBlackList(string) []string AsyncGetApplyList(int64, string, func(int32, string, int64, []string)) + AsyncAddFriend(string, string, func(int32, string)) + AsyncAccpetApply(string, string, func(int32, string)) + AsyncRejectApply(string, string, func(int32, string)) + AsynDeleteFriend(string, string, func(int32, string)) + AsyncAddBlack(string, string, func(int32, string)) + AsyncRemoveBlack(string, string, func(int32, string)) } type Guild interface { diff --git a/server/imserver_new/friend/friendmgr.go b/server/imserver_new/friend/friendmgr.go index 90e7b16e..a23e6aa2 100644 --- a/server/imserver_new/friend/friendmgr.go +++ b/server/imserver_new/friend/friendmgr.go @@ -93,3 +93,27 @@ func (this *FriendMgr) getFriends(accountId string) *map[string]int32 { 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) AsyncAccpetApply(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) AsyncAddBlack(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/player/player.go b/server/imserver_new/player/player.go index 3a0cab0d..128257e3 100644 --- a/server/imserver_new/player/player.go +++ b/server/imserver_new/player/player.go @@ -162,6 +162,18 @@ func (this *player) CMBlacklist(hdr *f5.MsgHdr, msg *cs.CMBlacklist) { } func (this *player) CMAddFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAddFriendRequest) { + rspMsg := new(cs.SMAddFriendRequest) + if GetFriendMgr().IsFriend(this.GetAccountId(), msg.GetTargetAccountId()) { + rspMsg.IsFriendship = proto.Int32(1) + this.SendMsg(rspMsg) + return + } + GetFriendMgr().AsyncAddFriend( + this.GetAccountId(), + msg.GetTargetAccountId(), + func (errCode int32, errMsg string) { + + }) } func (this *player) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAcceptFriendRequest) {