コード例 #1
0
ファイル: ChannelAPI.cs プロジェクト: mdX7/WoWLegionCompanion
        public void UpdateChannelAttributes(ChannelAPI.ChannelData channelData, List <bnet.protocol.attribute.Attribute> attributeList, RPCContextDelegate callback)
        {
            UpdateChannelStateRequest updateChannelStateRequest = new UpdateChannelStateRequest();

            bnet.protocol.channel.ChannelState channelState = new bnet.protocol.channel.ChannelState();
            foreach (bnet.protocol.attribute.Attribute val in attributeList)
            {
                channelState.AddAttribute(val);
            }
            updateChannelStateRequest.SetStateChange(channelState);
            this.m_rpcConnection.QueueRequest(this.m_channelService.Id, 4u, updateChannelStateRequest, callback, (uint)channelData.m_objectId);
        }
コード例 #2
0
        public void UpdateChannelAttributes(ChannelAPI.ChannelData channelData, List <Attribute> attributeList, RPCContextDelegate callback)
        {
            UpdateChannelStateRequest updateChannelStateRequest = new UpdateChannelStateRequest();

            bnet.protocol.channel.ChannelState channelState = new bnet.protocol.channel.ChannelState();
            using (List <Attribute> .Enumerator enumerator = attributeList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Attribute current = enumerator.get_Current();
                    channelState.AddAttribute(current);
                }
            }
            updateChannelStateRequest.SetStateChange(channelState);
            this.m_rpcConnection.QueueRequest(this.m_channelService.Id, 4u, updateChannelStateRequest, callback, (uint)channelData.m_objectId);
        }
コード例 #3
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());
                        }
                    }
                }
            }
        }