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(); } }
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(); } }