public void Translate(Client client, byte packetId, PacketIn packet) { if (!Handlers.ContainsKey(packetId)) { ServerConsole.WriteLine("Unknown Packet Detected.", MessageLevel.Warning); PacketTranslator.DumpUnknown(client, packet); } else { try { Handlers[packetId](client, packet); } catch (Exception ex) { ServerConsole.WriteLine("Translator Error: {0} for packet {1}", MessageLevel.Error, ex.ToString(), packetId); } } }
public static void DumpUnusedPacket(string name, PacketIn packet) { ServerConsole.WriteLine("Dumping unused packet #{0} with Id {1:X2}: ",MessageLevel.Warning, name, packet.PacketType); for (int i = 0; i < (packet.PacketSize - 3); i++) { ServerConsole.WriteLine("{0} ",MessageLevel.Warning, packet.ReadByte()); } ServerConsole.WriteLine(""); }
public static void DumpUnknown(PacketIn packet) { ServerConsole.WriteLine("Dumping unknown packet with Id {0:X2}: ",MessageLevel.Warning, packet.PacketType); for (int i = 0; i < (packet.PacketSize - 3); i++) { ServerConsole.WriteLine("{0} ", MessageLevel.Warning, packet.ReadByte()); } ServerConsole.WriteLine(""); }
/// <summary> /// Process a packet input /// </summary> /// <param name="buffer"></param> public void Process(byte[] buffer) { try { PacketIn packet = new PacketIn(buffer, packetKey); handler.Translate(this, packet.PacketType, packet); if (packet.PacketType == 0xA3) { ServerConsole.WriteLine("0xa3 packet type"); return; } if (packetKey == 63) { packetKey = 0; } else { packetKey++; } } catch (Exception ex) { ServerConsole.WriteLine("Packet Error: {0}", MessageLevel.Error, ex.Message, ex.TargetSite.Name); } }