Example #1
0
        private void HandleChannelInvitation_NotifyReceivedSuggestionAdded(RPCContext context)
        {
            SuggestionAddedNotification suggestionAddedNotification = SuggestionAddedNotification.ParseFrom(context.Payload);
            EntityId entityId = (!suggestionAddedNotification.Suggestion.HasChannelId) ? null : suggestionAddedNotification.Suggestion.ChannelId;

            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(entityId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelInvitation_NotifyReceivedSuggestionAdded had unexpected traffic for channelId: " + entityId);
                return;
            }
            base.ApiLog.LogDebug("HandleChannelInvitation_NotifyReceivedSuggestionAdded: " + suggestionAddedNotification);
            if (this.m_receivedInviteRequests == null)
            {
                this.m_receivedInviteRequests = new Map <EntityId, List <Suggestion> >();
            }
            List <Suggestion> list;

            if (!this.m_receivedInviteRequests.TryGetValue(entityId, out list))
            {
                list = new List <Suggestion>();
                this.m_receivedInviteRequests[entityId] = list;
            }
            if (list.IndexOf(suggestionAddedNotification.Suggestion) < 0)
            {
                list.Add(suggestionAddedNotification.Suggestion);
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            if (channelType == ChannelAPI.ChannelType.PARTY_CHANNEL)
            {
                this.m_battleNet.Party.ReceivedInviteRequestDelta(entityId, suggestionAddedNotification.Suggestion, default(uint?));
            }
        }
Example #2
0
        private void HandleChannelSubscriber_NotifyJoin(RPCContext context)
        {
            JoinNotification joinNotification = JoinNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyJoin: " + joinNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyJoin had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            switch (channelType)
            {
            case ChannelAPI.ChannelType.PRESENCE_CHANNEL:
                goto IL_103;
            }
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            if (channelData != null)
            {
                EntityId gameAccountId = joinNotification.Member.Identity.GameAccountId;
                channelData.m_members.Add(gameAccountId, joinNotification.Member);
                if (!this.m_battleNet.GameAccountId.Equals(gameAccountId))
                {
                    this.m_battleNet.Presence.PresenceSubscribe(joinNotification.Member.Identity.GameAccountId);
                }
            }
IL_103:
            if (channelType == ChannelAPI.ChannelType.PARTY_CHANNEL)
            {
                this.m_battleNet.Party.PartyMemberJoined(channelReferenceObject, joinNotification);
            }
        }
Example #3
0
        private void HandleChannelSubscriber_NotifyLeave(RPCContext context)
        {
            LeaveNotification leaveNotification = LeaveNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyLeave: " + leaveNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyLeave had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            if (channelType != ChannelAPI.ChannelType.PARTY_CHANNEL)
            {
                if (channelType != ChannelAPI.ChannelType.CHAT_CHANNEL && channelType != ChannelAPI.ChannelType.GAME_CHANNEL)
                {
                    return;
                }
            }
            else
            {
                this.m_battleNet.Party.PartyMemberLeft(channelReferenceObject, leaveNotification);
            }
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            if (channelData != null)
            {
                channelData.m_members.Remove(leaveNotification.MemberId);
                if (!this.m_battleNet.GameAccountId.Equals(leaveNotification.MemberId))
                {
                    this.m_battleNet.Presence.PresenceUnsubscribe(leaveNotification.MemberId);
                }
            }
        }
Example #4
0
        public void JoinChannel(EntityId channelId, ChannelAPI.ChannelType channelType)
        {
            JoinChannelRequest joinChannelRequest = new JoinChannelRequest();

            joinChannelRequest.SetChannelId(channelId);
            joinChannelRequest.SetObjectId(ChannelAPI.GetNextObjectId());
            ChannelAPI.ChannelData channelData = new ChannelAPI.ChannelData(this, channelId, 0uL, channelType);
            channelData.SetSubscriberObjectId(joinChannelRequest.ObjectId);
            this.m_rpcConnection.QueueRequest(this.m_channelOwnerService.Id, 3u, joinChannelRequest, new RPCContextDelegate(channelData.JoinChannelCallback), (uint)channelType);
        }
Example #5
0
        public void AcceptInvitation(ulong invitationId, EntityId channelId, ChannelAPI.ChannelType channelType, RPCContextDelegate callback = null)
        {
            AcceptInvitationRequest acceptInvitationRequest = new AcceptInvitationRequest();

            acceptInvitationRequest.SetInvitationId(invitationId);
            acceptInvitationRequest.SetObjectId(ChannelAPI.GetNextObjectId());
            ChannelAPI.ChannelData channelData = new ChannelAPI.ChannelData(this, channelId, 0uL, channelType);
            channelData.SetSubscriberObjectId(acceptInvitationRequest.ObjectId);
            this.m_rpcConnection.QueueRequest(ChannelAPI.m_channelInvitationService.Id, 4u, acceptInvitationRequest, delegate(RPCContext ctx)
            {
                channelData.AcceptInvitationCallback(ctx, callback);
            }, 0u);
        }
Example #6
0
        private void HandleChannelSubscriber_NotifySendMessage(RPCContext context)
        {
            SendMessageNotification sendMessageNotification = SendMessageNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifySendMessage: " + sendMessageNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifySendMessage had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            if (channelType == ChannelAPI.ChannelType.PARTY_CHANNEL)
            {
                this.m_battleNet.Party.PartyMessageReceived(channelReferenceObject, sendMessageNotification);
            }
        }
Example #7
0
        private void HandleChannelSubscriber_NotifyAdd(RPCContext context)
        {
            AddNotification addNotification = AddNotification.ParseFrom(context.Payload);

            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyAdd had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyAdd: " + addNotification);
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            switch (channelType)
            {
            case ChannelAPI.ChannelType.PRESENCE_CHANNEL:
                if (addNotification.ChannelState.HasPresence)
                {
                    bnet.protocol.presence.ChannelState presence = addNotification.ChannelState.Presence;
                    this.m_battleNet.Presence.HandlePresenceUpdates(presence, channelReferenceObject);
                }
                goto IL_16E;
            }
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            if (channelData != null)
            {
                channelData.m_channelState = addNotification.ChannelState;
                using (List <Member> .Enumerator enumerator = addNotification.MemberList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Member   current       = enumerator.get_Current();
                        EntityId gameAccountId = current.Identity.GameAccountId;
                        channelData.m_members.Add(gameAccountId, current);
                        if (!this.m_battleNet.GameAccountId.Equals(gameAccountId))
                        {
                            this.m_battleNet.Presence.PresenceSubscribe(current.Identity.GameAccountId);
                        }
                    }
                }
            }
IL_16E:
            if (channelType == ChannelAPI.ChannelType.PARTY_CHANNEL)
            {
                this.m_battleNet.Party.PartyJoined(channelReferenceObject, addNotification);
            }
        }
Example #8
0
        private void HandleChannelSubscriber_NotifyRemove(RPCContext context)
        {
            RemoveNotification removeNotification = RemoveNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyRemove: " + removeNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyRemove had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            if (channelType != ChannelAPI.ChannelType.PARTY_CHANNEL)
            {
                if (channelType != ChannelAPI.ChannelType.GAME_CHANNEL)
                {
                    if (channelType != ChannelAPI.ChannelType.CHAT_CHANNEL)
                    {
                        goto IL_147;
                    }
                }
                else
                {
                    this.m_battleNet.Games.GameLeft(channelReferenceObject, removeNotification);
                }
            }
            else
            {
                this.m_battleNet.Party.PartyLeft(channelReferenceObject, removeNotification);
            }
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            if (channelData != null)
            {
                foreach (Member member in channelData.m_members.Values)
                {
                    if (!this.m_battleNet.GameAccountId.Equals(member.Identity.GameAccountId))
                    {
                        this.m_battleNet.Presence.PresenceUnsubscribe(member.Identity.GameAccountId);
                    }
                }
            }
IL_147:
            this.RemoveActiveChannel(context.Header.ObjectId);
        }
Example #9
0
        private void HandleChannelSubscriber_NotifyUpdateMemberState(RPCContext context)
        {
            UpdateMemberStateNotification updateMemberStateNotification = UpdateMemberStateNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyUpdateMemberState: " + updateMemberStateNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyUpdateMemberState had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            EntityId        channelId          = channelData.m_channelId;
            List <EntityId> list = null;

            for (int i = 0; i < updateMemberStateNotification.StateChangeList.get_Count(); i++)
            {
                Member deltaMember = updateMemberStateNotification.StateChangeList.get_Item(i);
                if (!deltaMember.Identity.HasGameAccountId)
                {
                    base.ApiLog.LogError("HandleChannelSubscriber_NotifyUpdateMemberState no identity/gameAccount in Member list at index={0} channelId={1}-{2}", new object[]
                    {
                        i,
                        channelId.High,
                        channelId.Low
                    });
                }
                else
                {
                    EntityId gameAccountId    = deltaMember.Identity.GameAccountId;
                    Map <string, Variant> map = null;
                    Member member;
                    Member cachedMember;
                    if (!channelData.m_members.TryGetValue(gameAccountId, out cachedMember))
                    {
                        member = deltaMember;
                    }
                    else
                    {
                        Member      cachedMember2 = cachedMember;
                        MemberState state         = cachedMember.State;
                        if (deltaMember.State.AttributeCount > 0)
                        {
                            if (map == null)
                            {
                                map = new Map <string, Variant>();
                            }
                            for (int j = 0; j < deltaMember.State.AttributeCount; j++)
                            {
                                Attribute attribute = deltaMember.State.AttributeList.get_Item(j);
                                int       num       = -1;
                                for (int k = 0; k < state.AttributeList.get_Count(); k++)
                                {
                                    Attribute attribute2 = state.AttributeList.get_Item(k);
                                    if (attribute2.Name == attribute.Name)
                                    {
                                        num = k;
                                        break;
                                    }
                                }
                                if (attribute.Value.IsNone())
                                {
                                    if (num >= 0)
                                    {
                                        state.AttributeList.RemoveAt(num);
                                    }
                                }
                                else if (num >= 0)
                                {
                                    state.Attribute.set_Item(num, attribute);
                                }
                                else
                                {
                                    state.AddAttribute(attribute);
                                }
                                map.Add(attribute.Name, attribute.Value);
                            }
                        }
                        else
                        {
                            if (deltaMember.State.HasPrivileges)
                            {
                                state.Privileges = deltaMember.State.Privileges;
                            }
                            if (cachedMember.State.RoleCount != deltaMember.State.RoleCount || !Enumerable.All <uint>(cachedMember.State.RoleList, (uint roleId) => deltaMember.State.RoleList.Contains(roleId)) || !Enumerable.All <uint>(deltaMember.State.RoleList, (uint roleId) => cachedMember.State.RoleList.Contains(roleId)))
                            {
                                if (list == null)
                                {
                                    list = new List <EntityId>();
                                }
                                list.Add(gameAccountId);
                                state.ClearRole();
                                state.Role.AddRange(deltaMember.State.RoleList);
                            }
                            if (deltaMember.State.HasInfo)
                            {
                                if (state.HasInfo)
                                {
                                    if (deltaMember.State.Info.HasBattleTag)
                                    {
                                        state.Info.SetBattleTag(deltaMember.State.Info.BattleTag);
                                    }
                                }
                                else
                                {
                                    state.SetInfo(deltaMember.State.Info);
                                }
                            }
                        }
                        cachedMember2.SetState(state);
                        member = cachedMember2;
                    }
                    if (member != null)
                    {
                        channelData.m_members[gameAccountId] = member;
                    }
                    if (map != null)
                    {
                    }
                }
            }
            if (list != null)
            {
                bool flag = channelType == ChannelAPI.ChannelType.PARTY_CHANNEL;
                if (flag)
                {
                    this.m_battleNet.Party.MemberRolesChanged(channelReferenceObject, list);
                }
            }
        }
Example #10
0
        private void HandleChannelSubscriber_NotifyUpdateChannelState(RPCContext context)
        {
            UpdateChannelStateNotification updateChannelStateNotification = UpdateChannelStateNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyUpdateChannelState: " + updateChannelStateNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyUpdateChannelState had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            switch (channelType)
            {
            case ChannelAPI.ChannelType.PRESENCE_CHANNEL:
                if (updateChannelStateNotification.StateChange.HasPresence)
                {
                    bnet.protocol.presence.ChannelState presence = updateChannelStateNotification.StateChange.Presence;
                    this.m_battleNet.Presence.HandlePresenceUpdates(presence, channelReferenceObject);
                }
                return;

            case ChannelAPI.ChannelType.CHAT_CHANNEL:
            case ChannelAPI.ChannelType.GAME_CHANNEL:
                break;

            case ChannelAPI.ChannelType.PARTY_CHANNEL:
                this.m_battleNet.Party.PreprocessPartyChannelUpdated(channelReferenceObject, updateChannelStateNotification);
                break;

            default:
                return;
            }
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            if (channelData != null)
            {
                bool flag  = channelType == ChannelAPI.ChannelType.PARTY_CHANNEL;
                bool flag2 = false;
                Map <string, Variant> map = null;
                bnet.protocol.channel.ChannelState channelState = channelData.m_channelState;
                bnet.protocol.channel.ChannelState stateChange  = updateChannelStateNotification.StateChange;
                if (stateChange.HasMaxMembers)
                {
                    channelState.MaxMembers = stateChange.MaxMembers;
                }
                if (stateChange.HasMinMembers)
                {
                    channelState.MinMembers = stateChange.MinMembers;
                }
                if (stateChange.HasMaxInvitations)
                {
                    channelState.MaxInvitations = stateChange.MaxInvitations;
                }
                if (stateChange.HasPrivacyLevel && channelState.PrivacyLevel != stateChange.PrivacyLevel)
                {
                    channelState.PrivacyLevel = stateChange.PrivacyLevel;
                    flag2 = true;
                }
                if (stateChange.HasName)
                {
                    channelState.Name = stateChange.Name;
                }
                if (stateChange.HasDelegateName)
                {
                    channelState.DelegateName = stateChange.DelegateName;
                }
                if (stateChange.HasChannelType)
                {
                    if (!flag)
                    {
                        channelState.ChannelType = stateChange.ChannelType;
                    }
                    if (flag && stateChange.ChannelType != PartyAPI.PARTY_TYPE_DEFAULT)
                    {
                        channelState.ChannelType = stateChange.ChannelType;
                        int num = -1;
                        for (int i = 0; i < channelState.AttributeList.get_Count(); i++)
                        {
                            if (channelState.AttributeList.get_Item(i).Name == "WTCG.Party.Type")
                            {
                                num = i;
                                break;
                            }
                        }
                        Attribute attribute = ProtocolHelper.CreateAttribute("WTCG.Party.Type", channelState.ChannelType);
                        if (num >= 0)
                        {
                            channelState.AttributeList.set_Item(num, attribute);
                        }
                        else
                        {
                            channelState.AttributeList.Add(attribute);
                        }
                    }
                }
                if (stateChange.HasProgram)
                {
                    channelState.Program = stateChange.Program;
                }
                if (stateChange.HasAllowOfflineMembers)
                {
                    channelState.AllowOfflineMembers = stateChange.AllowOfflineMembers;
                }
                if (stateChange.HasSubscribeToPresence)
                {
                    channelState.SubscribeToPresence = stateChange.SubscribeToPresence;
                }
                if (stateChange.AttributeCount > 0 && map == null)
                {
                    map = new Map <string, Variant>();
                }
                for (int j = 0; j < stateChange.AttributeCount; j++)
                {
                    Attribute attribute2 = stateChange.AttributeList.get_Item(j);
                    int       num2       = -1;
                    for (int k = 0; k < channelState.AttributeList.get_Count(); k++)
                    {
                        Attribute attribute3 = channelState.AttributeList.get_Item(k);
                        if (attribute3.Name == attribute2.Name)
                        {
                            num2 = k;
                            break;
                        }
                    }
                    if (attribute2.Value.IsNone())
                    {
                        if (num2 >= 0)
                        {
                            channelState.AttributeList.RemoveAt(num2);
                        }
                    }
                    else if (num2 >= 0)
                    {
                        channelState.Attribute.set_Item(num2, attribute2);
                    }
                    else
                    {
                        channelState.AddAttribute(attribute2);
                    }
                    map.Add(attribute2.Name, attribute2.Value);
                }
                if (stateChange.HasReason)
                {
                    IList <Invitation> invitationList  = stateChange.InvitationList;
                    IList <Invitation> invitationList2 = channelState.InvitationList;
                    for (int l = 0; l < invitationList.get_Count(); l++)
                    {
                        Invitation invitation = invitationList.get_Item(l);
                        for (int m = 0; m < invitationList2.get_Count(); m++)
                        {
                            Invitation invitation2 = invitationList2.get_Item(m);
                            if (invitation2.Id == invitation.Id)
                            {
                                channelState.InvitationList.RemoveAt(m);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    channelState.Invitation.AddRange(stateChange.InvitationList);
                }
                channelData.m_channelState = channelState;
                if (flag)
                {
                    if (flag2)
                    {
                        this.m_battleNet.Party.PartyPrivacyChanged(channelData.m_channelId, channelState.PrivacyLevel);
                    }
                    if (stateChange.InvitationList.get_Count() > 0)
                    {
                        uint?removeReason = default(uint?);
                        if (stateChange.HasReason)
                        {
                            removeReason = new uint?(stateChange.Reason);
                        }
                        using (List <Invitation> .Enumerator enumerator = stateChange.InvitationList.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                Invitation current = enumerator.get_Current();
                                this.m_battleNet.Party.PartyInvitationDelta(channelData.m_channelId, current, removeReason);
                            }
                        }
                    }
                    if (map != null)
                    {
                        foreach (KeyValuePair <string, Variant> current2 in map)
                        {
                            this.m_battleNet.Party.PartyAttributeChanged(channelData.m_channelId, current2.get_Key(), current2.get_Value());
                        }
                    }
                }
            }
        }
Example #11
0
 public ChannelData(ChannelAPI channelAPI, EntityId entityId, ulong objectId, ChannelAPI.ChannelType channelType) : base(entityId, objectId, channelType)
 {
     this.m_channelState = new bnet.protocol.channel.ChannelState();
     this.m_members      = new Map <EntityId, Member>();
     this.m_channelAPI   = channelAPI;
 }
Example #12
0
 public BaseChannelData(EntityId entityId, ulong objectId, ChannelAPI.ChannelType channelType)
 {
     this.m_channelId   = entityId;
     this.m_channelType = channelType;
     this.m_objectId    = objectId;
 }
Example #13
0
 public ChannelReferenceObject(EntityId entityId, ChannelAPI.ChannelType channelType)
 {
     this.m_channelData = new ChannelAPI.BaseChannelData(entityId, 0uL, channelType);
 }