예제 #1
0
        public static void HandleAccept(MooNetClient client, bnet.protocol.invitation.GenericRequest request)
        {
            if (!OnGoingInvitations.ContainsKey(request.InvitationId))
            {
                return;
            }
            var invitation = OnGoingInvitations[request.InvitationId];

            var inviter         = AccountManager.GetAccountByPersistentID(invitation.InviterIdentity.AccountId.Low);
            var invitee         = AccountManager.GetAccountByPersistentID(invitation.InviteeIdentity.AccountId.Low);
            var inviteeAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(invitation.InviteeIdentity.AccountId).Build();
            var inviterAsFriend = bnet.protocol.friends.Friend.CreateBuilder().SetId(invitation.InviterIdentity.AccountId).Build();

            var notificationToInviter = bnet.protocol.friends.InvitationNotification.CreateBuilder()
                                        .SetGameAccountId(invitee.BnetEntityId)
                                        .SetInvitation(invitation)
                                        .SetReason((uint)InvitationRemoveReason.Accepted) // success?
                                        .Build();

            var notificationToInvitee = bnet.protocol.friends.InvitationNotification.CreateBuilder()
                                        .SetGameAccountId(inviter.BnetEntityId)
                                        .SetInvitation(invitation)
                                        .SetReason((uint)InvitationRemoveReason.Accepted) // success?
                                        .Build();

            Friends.Add(invitee.BnetEntityId.Low, inviterAsFriend);
            Friends.Add(inviter.BnetEntityId.Low, inviteeAsFriend);
            AddFriendshipToDB(inviter, invitee);

            // send friend added notifications
            var friendAddedNotificationToInviter = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(inviteeAsFriend).SetGameAccountId(invitee.BnetEntityId).Build();
            var friendAddedNotificationToInvitee = bnet.protocol.friends.FriendNotification.CreateBuilder().SetTarget(inviterAsFriend).SetGameAccountId(inviter.BnetEntityId).Build();

            var inviterGameAccounts = GameAccountManager.GetGameAccountsForAccount(inviter);
            var inviteeGameAccounts = GameAccountManager.GetGameAccountsForAccount(invitee);

            foreach (var inviterGameAccount in inviterGameAccounts)
            {
                if (inviterGameAccount.IsOnline)
                {
                    inviterGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                                      bnet.protocol.friends.FriendsNotify.CreateStub(inviterGameAccount.LoggedInClient).NotifyReceivedInvitationRemoved(null, notificationToInviter, callback => { }));

                    inviterGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                                      bnet.protocol.friends.FriendsNotify.CreateStub(inviterGameAccount.LoggedInClient).NotifyFriendAdded(null, friendAddedNotificationToInviter, callback => { }));
                }
            }

            foreach (var inviteeGameAccount in inviteeGameAccounts)
            {
                if (inviteeGameAccount.IsOnline)
                {
                    inviteeGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                                      bnet.protocol.friends.FriendsNotify.CreateStub(inviteeGameAccount.LoggedInClient).NotifyFriendAdded(null, friendAddedNotificationToInvitee, callback => { }));

                    inviteeGameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                                      bnet.protocol.friends.FriendsNotify.CreateStub(inviteeGameAccount.LoggedInClient).NotifyReceivedInvitationRemoved(null, notificationToInvitee, callback => { }));
                }
            }
        }
예제 #2
0
        public void HandleDecline(MooNetClient client, bnet.protocol.invitation.GenericRequest request)
        {
            if (!this._onGoingInvitations.ContainsKey(request.InvitationId))
            {
                return;
            }
            var invitation = this._onGoingInvitations[request.InvitationId];

            var inviter = ToonManager.GetToonByLowID(invitation.InviterIdentity.ToonId.Low);

            if (inviter == null || inviter.Owner.LoggedInClient == null)
            {
                return;
            }

            var notification =
                bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder()
                .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0)) // caps have this set to high: 0 low: 0 /raist.
                .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder().AddInvitation(invitation)
                                .SetReason((uint)InvitationRemoveReason.Declined));

            this._onGoingInvitations.Remove(invitation.Id);

            // notify invoker about the decline.
            inviter.Owner.LoggedInClient.MakeTargetedRPC(inviter.Owner.LoggedInClient.CurrentChannel, () =>
                                                         bnet.protocol.channel.ChannelSubscriber.CreateStub(inviter.Owner.LoggedInClient).NotifyUpdateChannelState(null, notification.Build(), callback => { }));
        }
예제 #3
0
        public override void DeclineInvitation(IRpcController controller, bnet.protocol.invitation.GenericRequest request, Action <bnet.protocol.NoData> done)
        {
            Logger.Trace("{0} declined friend invitation.", this.Client.Account);

            var response = bnet.protocol.NoData.CreateBuilder();

            done(response.Build());

            FriendManager.HandleDecline(this.Client, request);
        }
예제 #4
0
        public static void HandleDecline(MooNetClient client, bnet.protocol.invitation.GenericRequest request)
        {
            if (!OnGoingInvitations.ContainsKey(request.InvitationId))
            {
                return;
            }
            var invitation = OnGoingInvitations[request.InvitationId];

            var inviter = AccountManager.GetAccountByPersistentID(invitation.InviterIdentity.AccountId.Low);
            var invitee = AccountManager.GetAccountByPersistentID(invitation.InviteeIdentity.AccountId.Low);

            var declinedNotification = bnet.protocol.friends.InvitationRemovedNotification.CreateBuilder()
                                       .SetInvitation(invitation)
                                       .SetReason((uint)InvitationRemoveReason.Declined).Build();

            inviter.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                   bnet.protocol.friends.FriendsNotify.CreateStub(inviter.LoggedInClient).NotifyReceivedInvitationRemoved(null, declinedNotification, callback => { }));

            invitee.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, () =>
                                                   bnet.protocol.friends.FriendsNotify.CreateStub(invitee.LoggedInClient).NotifyReceivedInvitationRemoved(null, declinedNotification, callback => { }));
        }
예제 #5
0
 public override void IgnoreInvitation(IRpcController controller, bnet.protocol.invitation.GenericRequest request, Action <bnet.protocol.NoData> done)
 {
     throw new NotImplementedException();
 }
예제 #6
0
        public override void DeclineInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.invitation.GenericRequest request, Action <bnet.protocol.NoData> done)
        {
            Logger.Trace("{0} declined invitation.", this.Client.Account.CurrentGameAccount.CurrentToon);

            var respone = bnet.protocol.NoData.CreateBuilder();

            done(respone.Build());

            this._invitationManager.HandleDecline(this.Client, request);
        }
예제 #7
0
 public override void DeclineInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.invitation.GenericRequest request, Action <bnet.protocol.NoData> done)
 {
     throw new NotImplementedException();
 }