public static void Serialize(Stream stream, GameFoundNotification instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            stream.WriteByte(9);
            binaryWriter.Write(instance.RequestId);
            if (instance.HasErrorCode)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.ErrorCode);
            }
            if (instance.HasGameHandle)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteUInt32(stream, instance.GameHandle.GetSerializedSize());
                GameHandle.Serialize(stream, instance.GameHandle);
            }
            if (instance.ConnectInfo.Count > 0)
            {
                foreach (ConnectInfo connectInfo in instance.ConnectInfo)
                {
                    stream.WriteByte(34);
                    ProtocolParser.WriteUInt32(stream, connectInfo.GetSerializedSize());
                    bnet.protocol.game_master.ConnectInfo.Serialize(stream, connectInfo);
                }
            }
        }
        public static GameFoundNotification DeserializeLengthDelimited(Stream stream, GameFoundNotification instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.Position;
            return(GameFoundNotification.Deserialize(stream, instance, num));
        }
        public static GameFoundNotification DeserializeLengthDelimited(Stream stream)
        {
            GameFoundNotification gameFoundNotification = new GameFoundNotification();

            GameFoundNotification.DeserializeLengthDelimited(stream, gameFoundNotification);
            return(gameFoundNotification);
        }
        public override bool Equals(object obj)
        {
            GameFoundNotification gameFoundNotification = obj as GameFoundNotification;

            if (gameFoundNotification == null)
            {
                return(false);
            }
            if (!this.RequestId.Equals(gameFoundNotification.RequestId))
            {
                return(false);
            }
            if (this.HasErrorCode != gameFoundNotification.HasErrorCode || (this.HasErrorCode && !this.ErrorCode.Equals(gameFoundNotification.ErrorCode)))
            {
                return(false);
            }
            if (this.HasGameHandle != gameFoundNotification.HasGameHandle || (this.HasGameHandle && !this.GameHandle.Equals(gameFoundNotification.GameHandle)))
            {
                return(false);
            }
            if (this.ConnectInfo.Count != gameFoundNotification.ConnectInfo.Count)
            {
                return(false);
            }
            for (int i = 0; i < this.ConnectInfo.Count; i++)
            {
                if (!this.ConnectInfo[i].Equals(gameFoundNotification.ConnectInfo[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #5
0
        public static void Serialize(Stream stream, GameFoundNotification instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            stream.WriteByte(9);
            binaryWriter.Write(instance.RequestId);
            if (instance.HasErrorCode)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.ErrorCode);
            }
            if (instance.HasGameHandle)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteUInt32(stream, instance.GameHandle.GetSerializedSize());
                GameHandle.Serialize(stream, instance.GameHandle);
            }
            if (instance.ConnectInfo.get_Count() > 0)
            {
                using (List <ConnectInfo> .Enumerator enumerator = instance.ConnectInfo.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ConnectInfo current = enumerator.get_Current();
                        stream.WriteByte(34);
                        ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                        bnet.protocol.game_master.ConnectInfo.Serialize(stream, current);
                    }
                }
            }
        }
 public void Serialize(Stream stream)
 {
     GameFoundNotification.Serialize(stream, this);
 }
        public static GameFoundNotification Deserialize(Stream stream, GameFoundNotification instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            instance.ErrorCode = 0u;
            if (instance.ConnectInfo == null)
            {
                instance.ConnectInfo = new List <ConnectInfo>();
            }
            while (limit < 0L || stream.Position < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else if (num != 9)
                {
                    if (num != 16)
                    {
                        if (num != 26)
                        {
                            if (num != 34)
                            {
                                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.ConnectInfo.Add(bnet.protocol.game_master.ConnectInfo.DeserializeLengthDelimited(stream));
                            }
                        }
                        else if (instance.GameHandle == null)
                        {
                            instance.GameHandle = GameHandle.DeserializeLengthDelimited(stream);
                        }
                        else
                        {
                            GameHandle.DeserializeLengthDelimited(stream, instance.GameHandle);
                        }
                    }
                    else
                    {
                        instance.ErrorCode = ProtocolParser.ReadUInt32(stream);
                    }
                }
                else
                {
                    instance.RequestId = binaryReader.ReadUInt64();
                }
            }
            if (stream.Position == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
 public static GameFoundNotification Deserialize(Stream stream, GameFoundNotification instance)
 {
     return(GameFoundNotification.Deserialize(stream, instance, -1L));
 }