ToByteArray() public method

Gets a copy of the internal byte buffer of the PacketBuilder.
public ToByteArray ( ) : byte[]
return byte[]
Beispiel #1
0
        private static byte[] ConstructHandshakePacketContent(HandshakeInfo handshakeInfo)
        {
            using (var builder = new PacketBuilder())
            {
                builder.WriteInt16(handshakeInfo.Version);
                builder.WriteLengthString(handshakeInfo.Subversion);
                builder.WriteBytes(handshakeInfo.ServerIv);
                builder.WriteBytes(handshakeInfo.ClientIv);

                // Locale ID (used for localizations and test servers)
                builder.WriteByte(handshakeInfo.LocaleId);

                return builder.ToByteArray();
            }
        }
Beispiel #2
0
        private static byte[] ConstructHandshakePacket(HandshakeInfo handshakeInfo)
        {
            var content = ConstructHandshakePacketContent(handshakeInfo);

            using (var builder = new PacketBuilder())
            {
                if (handshakeInfo.Header.HasValue)
                {
                    builder.WriteInt16(handshakeInfo.Header.Value);
                }
                else
                {
                    builder.WriteInt16((ushort)content.Length);
                }

                builder.WriteBytes(content);

                return builder.ToByteArray();
            }
        }