public static ConcurrentDictionary <int, ConcurrentDictionary <byte, byte> > ReadByteFieldDictionary(this ITypeReader serializer)
        {
            var result = new ConcurrentDictionary <int, ConcurrentDictionary <byte, byte> >();

            try
            {
                var cnt = serializer.ReadInt();
                for (int i = 0; i < cnt; i++)
                {
                    var key    = serializer.ReadInt();
                    var val    = new ConcurrentDictionary <byte, byte>();
                    var subCnt = serializer.ReadInt();
                    for (int j = 0; j < subCnt; j++)
                    {
                        var subKey   = serializer.ReadByte();
                        var subValue = serializer.ReadByte();
                        val.TryAdd(subKey, subValue);
                    }
                    result.TryAdd(key, val);
                }
            }
            catch (Exception e)
            {
                throw new Exception($"Error serializing ConcurrentDictionary<int, ConcurrentDictionary<ChangeFieldIndexes, byte>>: {e}");
            }

            return(result);
        }
 protected override void DeserializeRequestBody(ITypeReader typeReader)
 {
     RoomId             = typeReader.ReadGuid();
     CurrentPlayerCount = typeReader.ReadInt();
     State = (RoomState)typeReader.ReadByte();
     MaxMatchMakingWeight = typeReader.ReadInt();
 }
Exemplo n.º 3
0
 protected override void DeserializeBody(ITypeReader typeReader)
 {
     RoomId         = typeReader.ReadGuid();
     MaxPlayers     = typeReader.ReadInt();
     CurrentPlayers = typeReader.ReadInt();
     RoomProperties = typeReader.ReadDictionary <byte>(typeReader.ReadByte);
     State          = (RoomState)typeReader.ReadByte();
 }
 protected override void DeserializeBody(ITypeReader typeReader)
 {
     this.ResultCode = (ResultCode)typeReader.ReadByte();
     this.Message    = typeReader.ReadString();
     if (ResultCode == ResultCode.OK)
     {
         DeserializeResponseBody(typeReader);
     }
 }
Exemplo n.º 5
0
 protected override void DeserializeBody(ITypeReader typeReader)
 {
     ServerIpAddress = typeReader.ReadString();
     ServerPort      = typeReader.ReadUShort();
     RoomId          = typeReader.ReadGuid();
     Status          = (JoinStatus)typeReader.ReadByte();
     CurrentPlayers  = typeReader.ReadInt();
     MaxPlayers      = typeReader.ReadInt();
     JoinToExisting  = typeReader.ReadBool();
 }
Exemplo n.º 6
0
 public void Deserialize(ITypeReader typeReader)
 {
     ResultCode = (ResultCode)typeReader.ReadByte();
     Message    = typeReader.ReadString();
     if (ResultCode != ResultCode.OK)
     {
         return;
     }
     DeserializeResponseBody(typeReader);
 }
Exemplo n.º 7
0
        public static byte?ReadNullableByte(this ITypeReader typeWriter)
        {
            var notIsNull = typeWriter.ReadBool();

            if (notIsNull)
            {
                return(typeWriter.ReadByte());
            }

            return(null);
        }
        public void Deserialize(ITypeReader typeReader)
        {
            this.ServerRole = (ServerRole)typeReader.ReadByte();
            this.Address    = typeReader.ReadString();
            var count = typeReader.ReadInt();

            this.Ports = new List <ushort>();
            for (var i = 0; i < count; i++)
            {
                this.Ports.Add(typeReader.ReadUShort());
            }
            PortsString = typeReader.ReadString();
        }
Exemplo n.º 9
0
 protected override void DeserializeBody(ITypeReader typeReader)
 {
     Address       = typeReader.ReadString();
     Ports         = typeReader.ReadString();
     ServerRole    = (ServerRole)typeReader.ReadByte();
     Name          = typeReader.ReadString();
     Region        = typeReader.ReadString();
     ClientVersion = typeReader.ReadString();
     ActualizedOn  = typeReader.ReadNullableDate();
     IsApproved    = typeReader.ReadBool();
     PeerCount     = typeReader.ReadInt();
     HttpPort      = typeReader.ReadUShort();
     HttpsPort     = typeReader.ReadUShort();
 }
        public static List <byte> ReadListOfByte(this ITypeReader reader)
        {
            var list       = new List <byte>();
            var listLength = reader.ReadInt();

            if (listLength != 0)
            {
                for (int i = 0; i < listLength; i++)
                {
                    list.Add(reader.ReadByte());
                }
            }

            return(list);
        }
Exemplo n.º 11
0
        public static Dictionary <TKey, object> ReadDictionary <TKey>(this ITypeReader reader, Func <TKey> readKey)
        {
            var count = reader.ReadInt();
            var res   = new Dictionary <TKey, object>();

            for (int i = 0; i < count; i++)
            {
                var key   = readKey();
                var type  = SwitchValueToType[reader.ReadByte()];
                var value = SwitchRead[type](reader);
                res.Add(key, value);
            }

            return(res);
        }
Exemplo n.º 12
0
 public static Guid?ReadNullableGuid(this ITypeReader reader)
 {
     return(reader.ReadByte() != 0 ? reader.ReadGuid() : (Guid?)null);
 }
Exemplo n.º 13
0
 protected override void DeserializeResponseBody(ITypeReader typeReader)
 {
     this.MatchMakingErrorCode = (MatchMakingErrorCode)typeReader.ReadByte();
 }
Exemplo n.º 14
0
 protected override void DeserializeBody(ITypeReader typeReader)
 {
     PropertyCode = typeReader.ReadByte();
     ExactValue   = typeReader.ReadInt();
 }
 protected override void DeserializeResponseBody(ITypeReader typeReader)
 {
     CreatedDate = typeReader.ReadDate();
     State       = (RoomState)typeReader.ReadByte();
 }
Exemplo n.º 16
0
 public void Deserialize(ITypeReader typeReader)
 {
     OperationCode = typeReader.ReadByte();
     DeserializeBody(typeReader);
 }