public static void HandlePacket(WorldConnection connection, WORLDMSG msgID, BinReader data) { try { DebugLogger.Logger.Log("LoginClient handling packet " + msgID.ToString()); bool handled_packet = false; ILoginServerPacketHandler handler = (ILoginServerPacketHandler)loginServerHandlers[msgID]; if (handler != null) { handled_packet = true; handler.HandlePacket(connection, msgID, data); } LoginServerPacketDelegate wspd = (LoginServerPacketDelegate)loginServerDelegates[(int)msgID]; if (wspd != null) { handled_packet = true; wspd(connection, msgID, data); } if (handled_packet == false) { DebugLogger.Logger.Log("WARNING: No valid handler found for " + msgID.ToString()); } } catch (Exception exp) { DebugLogger.Logger.Log("", exp); } }
public static void RegisterPacketHandler(WORLDMSG msgID, ILoginServerPacketHandler handler) { if (loginServerHandlers.Contains(msgID)) { throw new Exception("There's already a loginserver packet handler for " + msgID); } loginServerHandlers[msgID] = handler; }
public static void HandlePacket(WorldConnection connection, WORLDMSG msgID, BinReader data) { ILoginServerPacketHandler handler = (ILoginServerPacketHandler)loginServerHandlers[msgID]; if (handler != null) { handler.HandlePacket(connection, msgID, data); } LoginServerPacketDelegate wspd = (LoginServerPacketDelegate)loginServerDelegates[(int)msgID]; if (wspd != null) { wspd(connection, msgID, data); } }