public Channel HandleAccept(MooNetClient client, bnet.protocol.channel_invitation.AcceptInvitationRequest request) { if (!this._onGoingInvitations.ContainsKey(request.InvitationId)) { return(null); } var invitation = this._onGoingInvitations[request.InvitationId]; var channel = ChannelManager.GetChannelByEntityId(invitation.GetExtension(bnet.protocol.channel_invitation.ChannelInvitation.ChannelInvitationProp).ChannelDescription.ChannelId); var notification = bnet.protocol.channel_invitation.InvitationRemovedNotification.CreateBuilder().SetInvitation(invitation.ToBuilder()).SetReason((uint)InvitationRemoveReason.Accepted); this._onGoingInvitations.Remove(invitation.Id); // notify invitee and let him remove the handled invitation. client.MakeTargetedRPC(this, () => bnet.protocol.channel_invitation.ChannelInvitationNotify.CreateStub(client).NotifyReceivedInvitationRemoved(null, notification.Build(), callback => { })); channel.Join(client, request.ObjectId); // add invitee to channel -- so inviter and other members will also be notified too. var inviter = GameAccountManager.GetAccountByPersistentID(invitation.InviterIdentity.AccountId.Low); var stateNotification = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0).Build()) .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder().AddRangeInvitation(channel.Invitations.Values).SetReason(0).Build()) .Build(); foreach (var member in channel.Members.Keys) { member.MakeTargetedRPC(channel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(member).NotifyUpdateChannelState(null, stateNotification, callback => { })); } return(channel); }
public Channel HandleAccept(MooNetClient client, bnet.protocol.channel_invitation.AcceptInvitationRequest request) { if (!this._onGoingInvitations.ContainsKey(request.InvitationId)) { return(null); } var invitation = this._onGoingInvitations[request.InvitationId]; var channel = ChannelManager.GetChannelByEntityId(invitation.GetExtension(bnet.protocol.channel_invitation.Invitation.ChannelInvitation).ChannelDescription.ChannelId); channel.Join(client, request.ObjectId); // add invitee to channel -- so inviter and other members will also be notified too. var notification = bnet.protocol.channel_invitation.InvitationRemovedNotification.CreateBuilder().SetInvitation(invitation).SetReason((uint)InvitationRemoveReason.Accepted); this._onGoingInvitations.Remove(invitation.Id); // notify invitee and let him remove the handled invitation. client.MakeTargetedRPC(this, () => bnet.protocol.channel_invitation.ChannelInvitationNotify.CreateStub(client).NotifyReceivedInvitationRemoved(null, notification.Build(), callback => { })); return(channel); }
public override void AcceptInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel_invitation.AcceptInvitationRequest request, Action <bnet.protocol.channel_invitation.AcceptInvitationResponse> done) { var channel = ChannelManager.GetChannelByEntityId(this._invitationManager.GetInvitationById(request.InvitationId).GetExtension(bnet.protocol.channel_invitation.ChannelInvitation.ChannelInvitationProp).ChannelDescription.ChannelId); Logger.Trace("{0} accepted invitation id {1} to channel {2}.", this.Client.Account.CurrentGameAccount.CurrentToon, request.InvitationId, channel); var response = bnet.protocol.channel_invitation.AcceptInvitationResponse.CreateBuilder().SetObjectId(channel.DynamicId).Build(); done(response); this._invitationManager.HandleAccept(this.Client, request); }
public override void AcceptInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel_invitation.AcceptInvitationRequest request, Action <bnet.protocol.channel_invitation.AcceptInvitationResponse> done) { Logger.Trace("{0} accepted invitation.", this.Client.CurrentToon); var channel = this._invitationManager.HandleAccept(this.Client, request); var response = bnet.protocol.channel_invitation.AcceptInvitationResponse.CreateBuilder().SetObjectId(channel.DynamicId).Build(); done(response); }