Beispiel #1
0
        public static void HandleRemove(MooNetClient client, bnet.protocol.friends.GenericFriendRequest request)
        {
            var removee = AccountManager.GetAccountByPersistentID(request.TargetId.Low);
            var remover = client.Account;

            var removeeAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(removee.BnetAccountID).Build();
            var removerAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(remover.BnetAccountID).Build();

            var removed = Friends.Remove(remover.BnetAccountID.Low, removeeAsFriend);

            if (!removed)
            {
                Logger.Warn("No friendship mapping between {0} and {1}", remover.BnetAccountID.Low, removeeAsFriend);
            }
            removed = Friends.Remove(removee.BnetAccountID.Low, removerAsFriend);
            if (!removed)
            {
                Logger.Warn("No friendship mapping between {0} and {1}", removee.BnetAccountID.Low, removerAsFriend);
            }
            RemoveFriendshipFromDB(remover, removee);

            var notifyRemover = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(removeeAsFriend).Build();

            client.MakeTargetedRPC(FriendManager.Instance, () =>
                                   bnet.protocol.friends.FriendsNotify.CreateStub(client).NotifyFriendRemoved(null, notifyRemover, callback => { }));

            if (removee.IsOnline)
            {
                var notifyRemovee = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(removerAsFriend).Build();
                removee.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                       bnet.protocol.friends.FriendsNotify.CreateStub(removee.LoggedInClient).NotifyFriendRemoved(null, notifyRemovee, callback => { }));
            }
        }
Beispiel #2
0
        public static void HandleRemove(MooNetClient client, bnet.protocol.friends.GenericFriendRequest request)
        {
            var removee = AccountManager.GetAccountByPersistentID(request.TargetId.Low);
            var remover = client.Account;

            var removeeAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(removee.BnetEntityId).Build();
            var removerAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(remover.BnetEntityId).Build();

            RemoveFriendshipFromDB(remover, removee);

            var notifyRemover = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(removeeAsFriend).Build();

            client.MakeTargetedRPC(FriendManager.Instance, () =>
                                   bnet.protocol.friends.FriendsNotify.CreateStub(client).NotifyFriendRemoved(null, notifyRemover, callback => { }));


            var removeeGameAccounts = GameAccountManager.GetGameAccountsForAccount(removee);

            foreach (var removeeGameAccount in removeeGameAccounts)
            {
                if (!removeeGameAccount.IsOnline)
                {
                    continue;
                }
                var notifyRemovee = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(removerAsFriend).Build();
                removeeGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                                  bnet.protocol.friends.FriendsNotify.CreateStub(removeeGameAccount.LoggedInClient).NotifyFriendRemoved(null, notifyRemovee, callback => { }));
            }
        }
Beispiel #3
0
        public override void RemoveFriend(IRpcController controller, bnet.protocol.friends.GenericFriendRequest request, Action <bnet.protocol.friends.GenericFriendResponse> done)
        {
            Logger.Trace("{0} removed friend with id {1}.", this.Client.Account, request.TargetId);

            var response = bnet.protocol.friends.GenericFriendResponse.CreateBuilder()
                           .SetTargetFriend(bnet.protocol.friends.Friend.CreateBuilder().SetId(request.TargetId).Build());

            done(response.Build());

            FriendManager.HandleRemove(this.Client, request);
        }