public static Challenge Deserialize(Stream stream, Challenge instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            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 != 13)
                    {
                        if (num2 != 18)
                        {
                            if (num2 != 26)
                            {
                                if (num2 != 32)
                                {
                                    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
                                {
                                    instance.Retries = ProtocolParser.ReadUInt32(stream);
                                }
                            }
                            else
                            {
                                instance.Answer = ProtocolParser.ReadString(stream);
                            }
                        }
                        else
                        {
                            instance.Info = ProtocolParser.ReadString(stream);
                        }
                    }
                    else
                    {
                        instance.Type = binaryReader.ReadUInt32();
                    }
                }
            }
            if (stream.get_Position() == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
 public void Deserialize(Stream stream)
 {
     Challenge.Deserialize(stream, this);
 }
 public static Challenge Deserialize(Stream stream, Challenge instance)
 {
     return(Challenge.Deserialize(stream, instance, -1L));
 }
        public override bool Equals(object obj)
        {
            Challenge challenge = obj as Challenge;

            return(challenge != null && this.Type.Equals(challenge.Type) && this.HasInfo == challenge.HasInfo && (!this.HasInfo || this.Info.Equals(challenge.Info)) && this.HasAnswer == challenge.HasAnswer && (!this.HasAnswer || this.Answer.Equals(challenge.Answer)) && this.HasRetries == challenge.HasRetries && (!this.HasRetries || this.Retries.Equals(challenge.Retries)));
        }
 public void Serialize(Stream stream)
 {
     Challenge.Serialize(stream, this);
 }
Example #6
0
        public static SendChallengeToUserRequest Deserialize(Stream stream, SendChallengeToUserRequest instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            if (instance.Challenges == null)
            {
                instance.Challenges = new List <Challenge>();
            }
            if (instance.Attributes == null)
            {
                instance.Attributes = new List <bnet.protocol.attribute.Attribute>();
            }
            while (true)
            {
                if (limit < (long)0 || stream.Position < limit)
                {
                    int num = stream.ReadByte();
                    if (num != -1)
                    {
                        switch (num)
                        {
                        case 37:
                        {
                            instance.Context = binaryReader.ReadUInt32();
                            continue;
                        }

                        case 40:
                        {
                            instance.Timeout = ProtocolParser.ReadUInt64(stream);
                            continue;
                        }

                        default:
                        {
                            if (num == 10)
                            {
                                if (instance.PeerId != null)
                                {
                                    ProcessId.DeserializeLengthDelimited(stream, instance.PeerId);
                                }
                                else
                                {
                                    instance.PeerId = ProcessId.DeserializeLengthDelimited(stream);
                                }
                                continue;
                            }
                            else if (num == 18)
                            {
                                if (instance.GameAccountId != null)
                                {
                                    EntityId.DeserializeLengthDelimited(stream, instance.GameAccountId);
                                }
                                else
                                {
                                    instance.GameAccountId = EntityId.DeserializeLengthDelimited(stream);
                                }
                                continue;
                            }
                            else if (num == 26)
                            {
                                instance.Challenges.Add(Challenge.DeserializeLengthDelimited(stream));
                                continue;
                            }
                            else if (num == 50)
                            {
                                instance.Attributes.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream));
                                continue;
                            }
                            else
                            {
                                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);
                                continue;
                            }
                        }
                        }
                    }
                    else
                    {
                        if (limit >= (long)0)
                        {
                            throw new EndOfStreamException();
                        }
                        break;
                    }
                }
                else
                {
                    if (stream.Position != limit)
                    {
                        throw new ProtocolBufferException("Read past max limit");
                    }
                    break;
                }
            }
            return(instance);
        }
Example #7
0
 public void AddChallenges(Challenge val)
 {
     this._Challenges.Add(val);
 }
        public static ChallengeUserRequest Deserialize(Stream stream, ChallengeUserRequest instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            if (instance.Challenges == null)
            {
                instance.Challenges = new List <Challenge>();
            }
            if (instance.Attributes == null)
            {
                instance.Attributes = new List <bnet.protocol.attribute.Attribute>();
            }
            while (limit < 0L || stream.Position < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else
                {
                    switch (num)
                    {
                    case 21:
                        instance.Context = binaryReader.ReadUInt32();
                        break;

                    default:
                        if (num != 10)
                        {
                            if (num != 32)
                            {
                                if (num != 42)
                                {
                                    if (num != 50)
                                    {
                                        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.GameAccountId == null)
                                    {
                                        instance.GameAccountId = EntityId.DeserializeLengthDelimited(stream);
                                    }
                                    else
                                    {
                                        EntityId.DeserializeLengthDelimited(stream, instance.GameAccountId);
                                    }
                                }
                                else
                                {
                                    instance.Attributes.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream));
                                }
                            }
                            else
                            {
                                instance.Deadline = ProtocolParser.ReadUInt64(stream);
                            }
                        }
                        else
                        {
                            instance.Challenges.Add(Challenge.DeserializeLengthDelimited(stream));
                        }
                        break;

                    case 24:
                        instance.Id = ProtocolParser.ReadUInt32(stream);
                        break;
                    }
                }
            }
            if (stream.Position == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }