public static void HandlePacket(WorldClient client, CMSG msgID, BinReader data) { DebugLogger.ILog("Handling CMSG packet: " + msgID); bool handled = false; try { IWorldClientPacketHandler handler = (IWorldClientPacketHandler)worldClientHandlers[msgID]; if (handler != null) { handler.HandlePacket(client, msgID, data); handled = true; } WorldClientPacketDelegate wcpd = (WorldClientPacketDelegate)worldClientDelegates[(int)msgID]; if (wcpd != null) { wcpd(client, msgID, data); handled = true; } } catch (Exception exp) { DebugLogger.Logger.Log("", exp); } if (handled == false) { DebugLogger.ILog("Unhandled CMSG: " + msgID.ToString()); } }
private static void OnLoginServerData(byte[] data) { BinReader read = new BinReader(data); read.BaseStream.Position += 4; // skip len WORLDMSG msgID = (WORLDMSG)read.ReadInt32(); if (msgID == WORLDMSG.CLIENT_MESSAGE) { uint charID = read.ReadUInt32(); CMSG cmsg = (CMSG)read.ReadInt32(); WorldClient client = GetClientByCharacterID(charID); if (client != null) { WorldPacketManager.HandlePacket(client, cmsg, read); } else { Console.WriteLine("Client(" + charID + ") was missing when " + cmsg.ToString() + " was received."); } } else if (msgID == WORLDMSG.SCRIPT_MESSAGE) { int msg = read.ReadInt32(); Scripts.OnScriptMessage(msg, read); } else { WorldPacketManager.HandlePacket(msgID, read); } }
public static void ToFile(BinReader data, CMSG msgID) { string msg = msgID.ToString() + " : \n"; msg += ToString(data.ReadBytes((int)data.Length()), (int)data.Length()); WriteToFile(msg); }
public static void ToFile(BinWriter data, CMSG msgID) { string msg = msgID.ToString() + " : \n"; msg += ToString(data.GetBuffer(), (int)data.BaseStream.Length); WriteToFile(msg); }
/// <summary> /// Returns false if the packet should be sent to the loginserver /// </summary> /// <param name="client"></param> /// <param name="msgID"></param> /// <param name="data"></param> /// <returns></returns> public static bool HandlePacket(LoginClient client, CMSG msgID, BinReader data) { DebugLogger.Logger.Log("LoginClient handling packet " + msgID.ToString()); if (msgID >= CMSG.MAX) { return(true); } ILoginClientPacketHandler handler = (ILoginClientPacketHandler)loginClientHandlers[msgID]; bool wasHandled = false; try { long position = data.BaseStream.Position; if (handler != null) { wasHandled = handler.HandlePacket(client, msgID, data); } data.BaseStream.Position = position; LoginClientPacketDelegate wcpd = (LoginClientPacketDelegate)loginClientDelegates[(int)msgID]; if (wcpd != null) { foreach (LoginClientPacketDelegate d in wcpd.GetInvocationList()) { if (d != null) { if (d(client, msgID, data)) { wasHandled = true; } data.BaseStream.Position = position; } } } return(wasHandled); } catch (Exception exp) { DebugLogger.Logger.Log("", exp); } return(wasHandled); }
private static void OnLoginServerData(ClientBase client, byte[] data) { try { BinReader read = new BinReader(data); read.BaseStream.Position += 4; // skip len WORLDMSG msgID = (WORLDMSG)read.ReadInt32(); if (msgID != WORLDMSG.DESERIALIZE_OBJ) { Console.WriteLine("OnLoginServerData read {0}", msgID); } if (msgID == WORLDMSG.CLIENT_MESSAGE) { uint charID = read.ReadUInt32(); CMSG cmsg = (CMSG)read.ReadInt32(); WorldClient world_client = GetClientByCharacterID(charID); if (client != null) { WorldPacketManager.HandlePacket(world_client, cmsg, read); } else { Console.WriteLine("Client(" + charID + ") was missing when " + cmsg.ToString() + " was received."); } } else if (msgID == WORLDMSG.SCRIPT_MESSAGE) { int msg = read.ReadInt32(); Console.WriteLine("Read SMSG: " + msg); Scripts.OnScriptMessage(msg, read); } else { WorldPacketManager.HandlePacket(msgID, read); } } catch (Exception exp) { DebugLogger.ILog("", exp); } }
public override string ToString() { return(base.ToString() + ", CMSG = " + m_clientMsgId.ToString() + " characterID = " + m_characterId.ToString()); }