/// <summary> /// Loads packet handlers to be used for handling incoming data from this game client. /// </summary> /// <param name="client"></param> public virtual void LoadPacketHandlers(string version, out IPacketHandler[] packetHandlers, out List <PacketHandlerAttribute> attributes) { packetHandlers = new IPacketHandler[256]; attributes = new List <PacketHandlerAttribute>(); Array.Clear(packetHandlers, 0, packetHandlers.Length); lock (PacketHandlerCacheLock) { if (!CachedPacketHandlerSearchResults.ContainsKey(version)) { int count = SearchAndAddPacketHandlers(version, Assembly.GetAssembly(typeof(GameServer)), packetHandlers); if (Log.IsInfoEnabled) { Log.Info($"PacketProcessor: Loaded {count} handlers from GameServer Assembly!"); } count = 0; foreach (Assembly asm in ScriptMgr.Scripts) { count += SearchAndAddPacketHandlers(version, asm, packetHandlers); } if (Log.IsInfoEnabled) { Log.Info($"PacketProcessor: Loaded {count} handlers from Script Assemblys!"); } // save search result for next login CachedPacketHandlerSearchResults.Add(version, (IPacketHandler[])packetHandlers.Clone()); } else { packetHandlers = (IPacketHandler[])CachedPacketHandlerSearchResults[version].Clone(); int count = 0; foreach (IPacketHandler ph in packetHandlers) { if (ph != null) { count++; } } Log.Info($"PacketProcessor: Loaded {count} handlers from cache for version={version}!"); } if (CachedPreprocessorSearchResults.ContainsKey(version)) { attributes = CachedPreprocessorSearchResults[version]; } Log.Info($"PacketProcessor: Loaded {attributes.Count} preprocessors from cache for version={version}!"); } }
/// <summary> /// Loads packet handlers to be used for handling incoming data from this game client. /// </summary> /// <param name="client"></param> public virtual void LoadPacketHandlers(string version, out IPacketHandler[] packetHandlers, out List<PacketHandlerAttribute> attributes) { packetHandlers = new IPacketHandler[256]; attributes = new List<PacketHandlerAttribute>(); Array.Clear(packetHandlers, 0, packetHandlers.Length); lock (m_packetHandlerCacheLock) { if (!m_cachedPacketHandlerSearchResults.ContainsKey(version)) { int count = SearchAndAddPacketHandlers(version, Assembly.GetAssembly(typeof(GameServer)), packetHandlers); if (log.IsInfoEnabled) log.Info("PacketProcessor: Loaded " + count + " handlers from GameServer Assembly!"); count = 0; foreach (Assembly asm in ScriptMgr.Scripts) { count += SearchAndAddPacketHandlers(version, asm, packetHandlers); } if (log.IsInfoEnabled) log.Info("PacketProcessor: Loaded " + count + " handlers from Script Assemblys!"); //save search result for next login m_cachedPacketHandlerSearchResults.Add(version, (IPacketHandler[])packetHandlers.Clone()); } else { packetHandlers = (IPacketHandler[])m_cachedPacketHandlerSearchResults[version].Clone(); int count = 0; foreach (IPacketHandler ph in packetHandlers) if (ph != null) count++; log.Info("PacketProcessor: Loaded " + count + " handlers from cache for version="+version+"!"); } if (m_cachedPreprocessorSearchResults.ContainsKey(version)) attributes = m_cachedPreprocessorSearchResults[version]; log.Info("PacketProcessor: Loaded " + attributes.Count + " preprocessors from cache for version=" + version + "!"); } }