Represents a class for constructing game packets.
This class exclusively uses little-endian byte order.
Наследование: IPacketBuilder, IDisposable
Пример #1
0
        public PacketBuilder CreatePacket(string label)
        {
            ushort code = this.packets.GetOutgoingCode(label);

            var builder = new PacketBuilder();
            builder.WriteInt16(code);
            return builder;
        }
Пример #2
0
 public void SetUp()
 {
     _builder = new PacketBuilder();
 }
Пример #3
0
        private static void ShouldThrowOde(Action<PacketBuilder> operation)
        {
            var builder = new PacketBuilder();
            builder.Dispose();

            builder
                .Invoking(operation)
                .ShouldThrow<ObjectDisposedException>();
        }
Пример #4
0
 public void SetUp()
 {
     this.builder = new PacketBuilder();
 }
Пример #5
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();
            }
        }
Пример #6
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();
            }
        }