예제 #1
0
        public HandshakeMessage(byte[] data)
        {
            if (data.Length < 12)
            {
                IsValid = false;
                Console.WriteLine("Dropping packet " + Helpers.ByteArrayToString(data) + " Invalid length");
                return;
            }

            MemoryStream stream = new MemoryStream(data);

            this.MessageType = (HandshakeMessageType)stream.ReadByte();

            if (!Enum.IsDefined(typeof(HandshakeMessageType), this.MessageType))
            {
                IsValid = false;
                Console.WriteLine("Dropping packet " + Helpers.ByteArrayToString(data) + " Invalid Type");
                return;
            }

            this.DataLength1 = stream.ReadLittleEndian3Bytes();
            this.Unk2        = stream.ReadLittleEndianShort();
            this.Unk3        = stream.ReadLittleEndian3Bytes();
            this.DataLength2 = stream.ReadLittleEndian3Bytes();
            this.Data        = new byte[data.Length - 12];
            Array.Copy(data, 12, this.Data, 0, this.Data.Length);
            stream.Close();
            IsValid = true;
        }
예제 #2
0
        public HandshakeMessage(HandshakeMessageType type, ProtocolVersion version, byte[] data)
        {
            if (data == null) {
                throw new AlertException(AlertDescription.InternalError,
                                         "Trying to create HandshakeMessage with null data");
            }

            Type = type;
            _version = version;
            _data = (byte[])data.Clone();
        }
예제 #3
0
        public HandshakeMessage(HandshakeMessageType type, ProtocolVersion version, byte[] data)
        {
            if (data == null)
            {
                throw new AlertException(AlertDescription.InternalError,
                                         "Trying to create HandshakeMessage with null data");
            }

            Type     = type;
            _version = version;
            _data    = (byte[])data.Clone();
        }
예제 #4
0
 public HandshakeMessage(HandshakeMessageType type, ProtocolVersion version)
 {
     Type = type;
     _version = version;
     _data = new byte[0];
 }
예제 #5
0
 public HandshakeMessage(HandshakeMessageType type, ProtocolVersion version)
 {
     Type     = type;
     _version = version;
     _data    = new byte[0];
 }