public object GetMessage(BlubSerializer serializer, ushort opCode, Stream stream)
        {
            if (!_typeLookup.TryGetValue(opCode, out var type))
            {
                throw new ProudException($"No type found for opcode {opCode}");
            }

            return(serializer.Deserialize(stream, type));
        }
        public object GetMessage(BlubSerializer serializer, ushort opCode, BinaryReader reader)
        {
            if (!_typeLookup.TryGetValue(opCode, out var type))
#if DEBUG
            { throw new ProudBadOpCodeException(opCode, reader.ReadToEnd()); }
#else
            { throw new ProudBadOpCodeException(opCode); }
#endif

            return(serializer.Deserialize(reader, type));
        }
Beispiel #3
0
            public NotifyServerConnectionHintMessage Deserialize(BlubSerializer serializer, BinaryReader reader)
            {
                var config     = serializer.Deserialize <NetConfigDto>(reader);
                var encodedKey = reader.ReadStruct();
                var sequence   = (DerSequence)Asn1Object.FromByteArray(encodedKey);
                var modulus    = ((DerInteger)sequence[0]).Value.ToByteArrayUnsigned();
                var exponent   = ((DerInteger)sequence[1]).Value.ToByteArrayUnsigned();
                var publicKey  = new RSAParameters {
                    Exponent = exponent, Modulus = modulus
                };

                return(new NotifyServerConnectionHintMessage(config, publicKey));
            }