Beispiel #1
0
        public override byte[] Encode()
        {
            byte[] frames = EncodeFrames();

            List <byte> result = new List <byte>();

            result.Add(EncodeTypeField());
            result.AddRange(ByteUtilities.GetBytes(Version));

            result.Add(DestinationConnectionId.Size);
            if (DestinationConnectionId.Size > 0)
            {
                result.AddRange(DestinationConnectionId.ToByteArray());
            }

            result.Add(SourceConnectionId.Size);
            if (SourceConnectionId.Size > 0)
            {
                result.AddRange(SourceConnectionId.ToByteArray());
            }

            result.AddRange(frames);

            return(result.ToArray());
        }
Beispiel #2
0
        public override byte[] Encode()
        {
            byte[] frames = EncodeFrames();

            List <byte> result = new List <byte>();

            result.Add((byte)(Type | (PacketNumber.Size - 1)));
            result.AddRange(ByteUtilities.GetBytes(Version));

            result.Add(DestinationConnectionId.Size);
            if (DestinationConnectionId.Size > 0)
            {
                result.AddRange(DestinationConnectionId.ToByteArray());
            }
            result.Add(SourceConnectionId.Size);
            if (SourceConnectionId.Size > 0)
            {
                result.AddRange(SourceConnectionId.ToByteArray());
            }

            // TODO: Implement Token
            byte[] tokenLength = new VariableInteger(0);
            byte[] length      = new VariableInteger(PacketNumber.Size + (UInt64)frames.Length);

            result.AddRange(tokenLength);
            result.AddRange(length);
            result.AddRange(PacketNumber.ToByteArray());
            result.AddRange(frames);

            return(result.ToArray());
        }