private void HandlePacket(byte typeA, byte typeB, byte flags1, byte flags2, byte[] data, uint position, uint size) { Logger.Write("[-->] Packet {0:X}-{1:X} (flags {2}) ({3} bytes)", typeA, typeB, (PacketFlags)flags1, size + 8); if (Logger.VerbosePackets && size > 0) // TODO: This is trimming too far? { var dataTrimmed = new byte[size]; for (var i = 0; i < size; i++) { dataTrimmed[i] = data[i]; } var info = string.Format("[-->] {0:X}-{1:X} Data:", typeA, typeB); Logger.WriteHex(info, dataTrimmed); } var packet = new byte[size]; Array.Copy(data, position, packet, 0, size); LogPacket(true, typeA, typeB, flags1, flags2, packet); var handler = PacketHandlers.GetHandlerFor(typeA, typeB); if (handler != null) { handler.HandlePacket(this, flags1, packet, 0, size); } else { Logger.WriteWarning("[!!!] UNIMPLEMENTED PACKET {0:X}-{1:X} - (Flags {2}) ({3} bytes)", typeA, typeB, (PacketFlags)flags1, size); } }
private void HandlePacket(byte typeA, byte typeB, byte flags1, byte flags2, byte[] data, uint position, uint size) { var handler = PacketHandlers.GetHandlerFor(typeA, typeB); string packetName; if (handler != null) { packetName = $"{handler.GetType().Name} ({typeA:X}-{typeB:X})"; } else { packetName = $"{typeA:X}-{typeB:X}"; } Logger.Write($"[-->] Packet {packetName} (flags {(PacketFlags)flags1}) ({size + 8} bytes)"); if (Logger.VerbosePackets && size > 0) // TODO: This is trimming too far? { var dataTrimmed = new byte[size]; for (var i = 0; i < size; i++) { dataTrimmed[i] = data[i]; } var info = string.Format("[-->] {0:X}-{1:X} Data:", typeA, typeB); Logger.WriteHex(info, dataTrimmed); } var packet = new byte[size]; Array.Copy(data, position, packet, 0, size); LogPacket(true, typeA, typeB, flags1, flags2, packet); if (handler != null) { handler.HandlePacket(this, flags1, packet, 0, size); } else { Logger.WriteWarning("[!!!] UNIMPLEMENTED PACKET {0:X}-{1:X} - (Flags {2}) ({3} bytes)", typeA, typeB, (PacketFlags)flags1, size); } // throw new NotImplementedException(); }
public void TestLoginLookup() { Assert.IsNotNull(PacketHandlers.GetHandlerFor(0x11, 0x0)); }