Пример #1
0
 public static ChannelDescription Deserialize(Stream stream, ChannelDescription instance, long limit)
 {
     while (limit < 0L || stream.Position < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else if (num != 10)
         {
             if (num != 16)
             {
                 if (num != 26)
                 {
                     Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                     uint field = key.Field;
                     if (field == 0u)
                     {
                         throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                     }
                     ProtocolParser.SkipKey(stream, key);
                 }
                 else if (instance.State == null)
                 {
                     instance.State = ChannelState.DeserializeLengthDelimited(stream);
                 }
                 else
                 {
                     ChannelState.DeserializeLengthDelimited(stream, instance.State);
                 }
             }
             else
             {
                 instance.CurrentMembers = ProtocolParser.ReadUInt32(stream);
             }
         }
         else if (instance.ChannelId == null)
         {
             instance.ChannelId = EntityId.DeserializeLengthDelimited(stream);
         }
         else
         {
             EntityId.DeserializeLengthDelimited(stream, instance.ChannelId);
         }
     }
     if (stream.Position == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
Пример #2
0
 public static UpdateChannelStateNotification Deserialize(Stream stream, UpdateChannelStateNotification instance, long limit)
 {
     while (true)
     {
         if (limit < (long)0 || stream.Position < limit)
         {
             int num = stream.ReadByte();
             if (num == -1)
             {
                 if (limit >= (long)0)
                 {
                     throw new EndOfStreamException();
                 }
                 break;
             }
             else if (num == 10)
             {
                 if (instance.AgentId != null)
                 {
                     EntityId.DeserializeLengthDelimited(stream, instance.AgentId);
                 }
                 else
                 {
                     instance.AgentId = EntityId.DeserializeLengthDelimited(stream);
                 }
             }
             else if (num != 18)
             {
                 Key key = ProtocolParser.ReadKey((byte)num, stream);
                 if (key.Field == 0)
                 {
                     throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                 }
                 ProtocolParser.SkipKey(stream, key);
             }
             else if (instance.StateChange != null)
             {
                 ChannelState.DeserializeLengthDelimited(stream, instance.StateChange);
             }
             else
             {
                 instance.StateChange = ChannelState.DeserializeLengthDelimited(stream);
             }
         }
         else
         {
             if (stream.Position != limit)
             {
                 throw new ProtocolBufferException("Read past max limit");
             }
             break;
         }
     }
     return(instance);
 }
Пример #3
0
        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);
        }
Пример #4
0
 public static UpdateChannelStateRequest Deserialize(Stream stream, UpdateChannelStateRequest instance, long limit)
 {
     while (limit < 0L || stream.get_Position() < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else
         {
             int num2 = num;
             if (num2 != 10)
             {
                 if (num2 != 18)
                 {
                     Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                     uint field = key.Field;
                     if (field == 0u)
                     {
                         throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                     }
                     ProtocolParser.SkipKey(stream, key);
                 }
                 else if (instance.StateChange == null)
                 {
                     instance.StateChange = ChannelState.DeserializeLengthDelimited(stream);
                 }
                 else
                 {
                     ChannelState.DeserializeLengthDelimited(stream, instance.StateChange);
                 }
             }
             else if (instance.AgentId == null)
             {
                 instance.AgentId = EntityId.DeserializeLengthDelimited(stream);
             }
             else
             {
                 EntityId.DeserializeLengthDelimited(stream, instance.AgentId);
             }
         }
     }
     if (stream.get_Position() == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
Пример #5
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);
        }
Пример #6
0
 public static void Serialize(Stream stream, UpdateChannelStateNotification instance)
 {
     if (instance.HasAgentId)
     {
         stream.WriteByte(10);
         ProtocolParser.WriteUInt32(stream, instance.AgentId.GetSerializedSize());
         EntityId.Serialize(stream, instance.AgentId);
     }
     if (instance.StateChange == null)
     {
         throw new ArgumentNullException("StateChange", "Required by proto specification.");
     }
     stream.WriteByte(18);
     ProtocolParser.WriteUInt32(stream, instance.StateChange.GetSerializedSize());
     ChannelState.Serialize(stream, instance.StateChange);
 }
 public static void Serialize(Stream stream, CreateChannelRequest instance)
 {
     if (instance.HasAgentIdentity)
     {
         stream.WriteByte(10);
         ProtocolParser.WriteUInt32(stream, instance.AgentIdentity.GetSerializedSize());
         Identity.Serialize(stream, instance.AgentIdentity);
     }
     if (instance.HasMemberState)
     {
         stream.WriteByte(18);
         ProtocolParser.WriteUInt32(stream, instance.MemberState.GetSerializedSize());
         MemberState.Serialize(stream, instance.MemberState);
     }
     if (instance.HasChannelState)
     {
         stream.WriteByte(26);
         ProtocolParser.WriteUInt32(stream, instance.ChannelState.GetSerializedSize());
         ChannelState.Serialize(stream, instance.ChannelState);
     }
     if (instance.HasChannelId)
     {
         stream.WriteByte(34);
         ProtocolParser.WriteUInt32(stream, instance.ChannelId.GetSerializedSize());
         EntityId.Serialize(stream, instance.ChannelId);
     }
     if (instance.HasObjectId)
     {
         stream.WriteByte(40);
         ProtocolParser.WriteUInt64(stream, instance.ObjectId);
     }
     if (instance.HasLocalAgent)
     {
         stream.WriteByte(50);
         ProtocolParser.WriteUInt32(stream, instance.LocalAgent.GetSerializedSize());
         EntityId.Serialize(stream, instance.LocalAgent);
     }
     if (instance.HasLocalMemberState)
     {
         stream.WriteByte(58);
         ProtocolParser.WriteUInt32(stream, instance.LocalMemberState.GetSerializedSize());
         MemberState.Serialize(stream, instance.LocalMemberState);
     }
 }
Пример #8
0
 public static void Serialize(Stream stream, ChannelDescription instance)
 {
     if (instance.ChannelId == null)
     {
         throw new ArgumentNullException("ChannelId", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteUInt32(stream, instance.ChannelId.GetSerializedSize());
     EntityId.Serialize(stream, instance.ChannelId);
     if (instance.HasCurrentMembers)
     {
         stream.WriteByte(16);
         ProtocolParser.WriteUInt32(stream, instance.CurrentMembers);
     }
     if (instance.HasState)
     {
         stream.WriteByte(26);
         ProtocolParser.WriteUInt32(stream, instance.State.GetSerializedSize());
         ChannelState.Serialize(stream, instance.State);
     }
 }
Пример #9
0
        public override bool Equals(object obj)
        {
            ChannelState channelState = obj as ChannelState;

            if (channelState == null)
            {
                return(false);
            }
            if (this.HasMaxMembers != channelState.HasMaxMembers || (this.HasMaxMembers && !this.MaxMembers.Equals(channelState.MaxMembers)))
            {
                return(false);
            }
            if (this.HasMinMembers != channelState.HasMinMembers || (this.HasMinMembers && !this.MinMembers.Equals(channelState.MinMembers)))
            {
                return(false);
            }
            if (this.Attribute.get_Count() != channelState.Attribute.get_Count())
            {
                return(false);
            }
            for (int i = 0; i < this.Attribute.get_Count(); i++)
            {
                if (!this.Attribute.get_Item(i).Equals(channelState.Attribute.get_Item(i)))
                {
                    return(false);
                }
            }
            if (this.Invitation.get_Count() != channelState.Invitation.get_Count())
            {
                return(false);
            }
            for (int j = 0; j < this.Invitation.get_Count(); j++)
            {
                if (!this.Invitation.get_Item(j).Equals(channelState.Invitation.get_Item(j)))
                {
                    return(false);
                }
            }
            return(this.HasMaxInvitations == channelState.HasMaxInvitations && (!this.HasMaxInvitations || this.MaxInvitations.Equals(channelState.MaxInvitations)) && this.HasReason == channelState.HasReason && (!this.HasReason || this.Reason.Equals(channelState.Reason)) && this.HasPrivacyLevel == channelState.HasPrivacyLevel && (!this.HasPrivacyLevel || this.PrivacyLevel.Equals(channelState.PrivacyLevel)) && this.HasName == channelState.HasName && (!this.HasName || this.Name.Equals(channelState.Name)) && this.HasDelegateName == channelState.HasDelegateName && (!this.HasDelegateName || this.DelegateName.Equals(channelState.DelegateName)) && this.HasChannelType == channelState.HasChannelType && (!this.HasChannelType || this.ChannelType.Equals(channelState.ChannelType)) && this.HasProgram == channelState.HasProgram && (!this.HasProgram || this.Program.Equals(channelState.Program)) && this.HasAllowOfflineMembers == channelState.HasAllowOfflineMembers && (!this.HasAllowOfflineMembers || this.AllowOfflineMembers.Equals(channelState.AllowOfflineMembers)) && this.HasSubscribeToPresence == channelState.HasSubscribeToPresence && (!this.HasSubscribeToPresence || this.SubscribeToPresence.Equals(channelState.SubscribeToPresence)) && this.HasChat == channelState.HasChat && (!this.HasChat || this.Chat.Equals(channelState.Chat)) && this.HasPresence == channelState.HasPresence && (!this.HasPresence || this.Presence.Equals(channelState.Presence)));
        }
Пример #10
0
 public static ChannelState Deserialize(Stream stream, ChannelState instance)
 {
     return(ChannelState.Deserialize(stream, instance, -1L));
 }
Пример #11
0
 public void SetStateChange(ChannelState val)
 {
     this.StateChange = val;
 }
Пример #12
0
        public static void Serialize(Stream stream, ChannelState instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.HasMaxMembers)
            {
                stream.WriteByte(8);
                ProtocolParser.WriteUInt32(stream, instance.MaxMembers);
            }
            if (instance.HasMinMembers)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.MinMembers);
            }
            if (instance.Attribute.get_Count() > 0)
            {
                using (List <Attribute> .Enumerator enumerator = instance.Attribute.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Attribute current = enumerator.get_Current();
                        stream.WriteByte(26);
                        ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                        bnet.protocol.attribute.Attribute.Serialize(stream, current);
                    }
                }
            }
            if (instance.Invitation.get_Count() > 0)
            {
                using (List <Invitation> .Enumerator enumerator2 = instance.Invitation.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        Invitation current2 = enumerator2.get_Current();
                        stream.WriteByte(34);
                        ProtocolParser.WriteUInt32(stream, current2.GetSerializedSize());
                        bnet.protocol.invitation.Invitation.Serialize(stream, current2);
                    }
                }
            }
            if (instance.HasMaxInvitations)
            {
                stream.WriteByte(40);
                ProtocolParser.WriteUInt32(stream, instance.MaxInvitations);
            }
            if (instance.HasReason)
            {
                stream.WriteByte(48);
                ProtocolParser.WriteUInt32(stream, instance.Reason);
            }
            if (instance.HasPrivacyLevel)
            {
                stream.WriteByte(56);
                ProtocolParser.WriteUInt64(stream, (ulong)((long)instance.PrivacyLevel));
            }
            if (instance.HasName)
            {
                stream.WriteByte(66);
                ProtocolParser.WriteBytes(stream, Encoding.get_UTF8().GetBytes(instance.Name));
            }
            if (instance.HasDelegateName)
            {
                stream.WriteByte(74);
                ProtocolParser.WriteBytes(stream, Encoding.get_UTF8().GetBytes(instance.DelegateName));
            }
            if (instance.HasChannelType)
            {
                stream.WriteByte(82);
                ProtocolParser.WriteBytes(stream, Encoding.get_UTF8().GetBytes(instance.ChannelType));
            }
            if (instance.HasProgram)
            {
                stream.WriteByte(93);
                binaryWriter.Write(instance.Program);
            }
            if (instance.HasAllowOfflineMembers)
            {
                stream.WriteByte(96);
                ProtocolParser.WriteBool(stream, instance.AllowOfflineMembers);
            }
            if (instance.HasSubscribeToPresence)
            {
                stream.WriteByte(104);
                ProtocolParser.WriteBool(stream, instance.SubscribeToPresence);
            }
            if (instance.HasChat)
            {
                stream.WriteByte(162);
                stream.WriteByte(6);
                ProtocolParser.WriteUInt32(stream, instance.Chat.GetSerializedSize());
                bnet.protocol.chat.ChannelState.Serialize(stream, instance.Chat);
            }
            if (instance.HasPresence)
            {
                stream.WriteByte(170);
                stream.WriteByte(6);
                ProtocolParser.WriteUInt32(stream, instance.Presence.GetSerializedSize());
                bnet.protocol.presence.ChannelState.Serialize(stream, instance.Presence);
            }
        }
Пример #13
0
 public void Serialize(Stream stream)
 {
     ChannelState.Serialize(stream, this);
 }
Пример #14
0
        public static ChannelState Deserialize(Stream stream, ChannelState instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            if (instance.Attribute == null)
            {
                instance.Attribute = new List <Attribute>();
            }
            if (instance.Invitation == null)
            {
                instance.Invitation = new List <Invitation>();
            }
            instance.PrivacyLevel        = ChannelState.Types.PrivacyLevel.PRIVACY_LEVEL_OPEN;
            instance.ChannelType         = "default";
            instance.Program             = 0u;
            instance.AllowOfflineMembers = false;
            instance.SubscribeToPresence = true;
            while (limit < 0L || stream.get_Position() < limit)
            {
                int num = stream.ReadByte();
                if (num != -1)
                {
                    int num2 = num;
                    switch (num2)
                    {
                    case 93:
                        instance.Program = binaryReader.ReadUInt32();
                        continue;

                    case 94:
                    case 95:
IL_C6:
                        if (num2 == 8)
                        {
                            instance.MaxMembers = ProtocolParser.ReadUInt32(stream);
                            continue;
                        }
                        if (num2 == 16)
                        {
                            instance.MinMembers = ProtocolParser.ReadUInt32(stream);
                            continue;
                        }
                        if (num2 == 26)
                        {
                            instance.Attribute.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream));
                            continue;
                        }
                        if (num2 == 34)
                        {
                            instance.Invitation.Add(bnet.protocol.invitation.Invitation.DeserializeLengthDelimited(stream));
                            continue;
                        }
                        if (num2 == 40)
                        {
                            instance.MaxInvitations = ProtocolParser.ReadUInt32(stream);
                            continue;
                        }
                        if (num2 == 48)
                        {
                            instance.Reason = ProtocolParser.ReadUInt32(stream);
                            continue;
                        }
                        if (num2 == 56)
                        {
                            instance.PrivacyLevel = (ChannelState.Types.PrivacyLevel)ProtocolParser.ReadUInt64(stream);
                            continue;
                        }
                        if (num2 == 66)
                        {
                            instance.Name = ProtocolParser.ReadString(stream);
                            continue;
                        }
                        if (num2 == 74)
                        {
                            instance.DelegateName = ProtocolParser.ReadString(stream);
                            continue;
                        }
                        if (num2 == 82)
                        {
                            instance.ChannelType = ProtocolParser.ReadString(stream);
                            continue;
                        }
                        if (num2 != 104)
                        {
                            Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                            uint field = key.Field;
                            if (field != 100u)
                            {
                                if (field != 101u)
                                {
                                    if (field == 0u)
                                    {
                                        throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                                    }
                                    ProtocolParser.SkipKey(stream, key);
                                }
                                else if (key.WireType == Wire.LengthDelimited)
                                {
                                    if (instance.Presence == null)
                                    {
                                        instance.Presence = bnet.protocol.presence.ChannelState.DeserializeLengthDelimited(stream);
                                    }
                                    else
                                    {
                                        bnet.protocol.presence.ChannelState.DeserializeLengthDelimited(stream, instance.Presence);
                                    }
                                }
                            }
                            else if (key.WireType == Wire.LengthDelimited)
                            {
                                if (instance.Chat == null)
                                {
                                    instance.Chat = bnet.protocol.chat.ChannelState.DeserializeLengthDelimited(stream);
                                }
                                else
                                {
                                    bnet.protocol.chat.ChannelState.DeserializeLengthDelimited(stream, instance.Chat);
                                }
                            }
                            continue;
                        }
                        instance.SubscribeToPresence = ProtocolParser.ReadBool(stream);
                        continue;

                    case 96:
                        instance.AllowOfflineMembers = ProtocolParser.ReadBool(stream);
                        continue;
                    }
                    goto IL_C6;
                }
                if (limit >= 0L)
                {
                    throw new EndOfStreamException();
                }
                return(instance);
            }
            if (stream.get_Position() == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
Пример #15
0
 public static CreateChannelRequest Deserialize(Stream stream, CreateChannelRequest instance, long limit)
 {
     while (limit < 0L || stream.Position < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else if (num != 10)
         {
             if (num != 18)
             {
                 if (num != 26)
                 {
                     if (num != 34)
                     {
                         if (num != 40)
                         {
                             if (num != 50)
                             {
                                 if (num != 58)
                                 {
                                     Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                                     uint field = key.Field;
                                     if (field == 0u)
                                     {
                                         throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                                     }
                                     ProtocolParser.SkipKey(stream, key);
                                 }
                                 else if (instance.LocalMemberState == null)
                                 {
                                     instance.LocalMemberState = MemberState.DeserializeLengthDelimited(stream);
                                 }
                                 else
                                 {
                                     MemberState.DeserializeLengthDelimited(stream, instance.LocalMemberState);
                                 }
                             }
                             else if (instance.LocalAgent == null)
                             {
                                 instance.LocalAgent = EntityId.DeserializeLengthDelimited(stream);
                             }
                             else
                             {
                                 EntityId.DeserializeLengthDelimited(stream, instance.LocalAgent);
                             }
                         }
                         else
                         {
                             instance.ObjectId = ProtocolParser.ReadUInt64(stream);
                         }
                     }
                     else if (instance.ChannelId == null)
                     {
                         instance.ChannelId = EntityId.DeserializeLengthDelimited(stream);
                     }
                     else
                     {
                         EntityId.DeserializeLengthDelimited(stream, instance.ChannelId);
                     }
                 }
                 else if (instance.ChannelState == null)
                 {
                     instance.ChannelState = ChannelState.DeserializeLengthDelimited(stream);
                 }
                 else
                 {
                     ChannelState.DeserializeLengthDelimited(stream, instance.ChannelState);
                 }
             }
             else if (instance.MemberState == null)
             {
                 instance.MemberState = MemberState.DeserializeLengthDelimited(stream);
             }
             else
             {
                 MemberState.DeserializeLengthDelimited(stream, instance.MemberState);
             }
         }
         else if (instance.AgentIdentity == null)
         {
             instance.AgentIdentity = Identity.DeserializeLengthDelimited(stream);
         }
         else
         {
             Identity.DeserializeLengthDelimited(stream, instance.AgentIdentity);
         }
     }
     if (stream.Position == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
Пример #16
0
 public static AddNotification Deserialize(Stream stream, AddNotification instance, long limit)
 {
     if (instance.Member == null)
     {
         instance.Member = new List <Member>();
     }
     while (limit < 0L || stream.get_Position() < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else
         {
             int num2 = num;
             if (num2 != 10)
             {
                 if (num2 != 18)
                 {
                     if (num2 != 26)
                     {
                         Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                         uint field = key.Field;
                         if (field == 0u)
                         {
                             throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                         }
                         ProtocolParser.SkipKey(stream, key);
                     }
                     else if (instance.ChannelState == null)
                     {
                         instance.ChannelState = ChannelState.DeserializeLengthDelimited(stream);
                     }
                     else
                     {
                         ChannelState.DeserializeLengthDelimited(stream, instance.ChannelState);
                     }
                 }
                 else
                 {
                     instance.Member.Add(bnet.protocol.channel.Member.DeserializeLengthDelimited(stream));
                 }
             }
             else if (instance.Self == null)
             {
                 instance.Self = bnet.protocol.channel.Member.DeserializeLengthDelimited(stream);
             }
             else
             {
                 bnet.protocol.channel.Member.DeserializeLengthDelimited(stream, instance.Self);
             }
         }
     }
     if (stream.get_Position() == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
Пример #17
0
 public void SetChannelState(ChannelState val)
 {
     this.ChannelState = val;
 }
Пример #18
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());
                        }
                    }
                }
            }
        }
Пример #19
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;
 }