public void ReceiveCallBack(IAsyncResult result) { try { socket = (Socket)result.AsyncState; if (!socket.Connected) { Disconnect(); return; } int size = socket.EndReceive(result); byte[] buffer = new byte[size]; Array.Copy(_buffer, buffer, buffer.Length); BigEndianReader reader = new BigEndianReader(buffer); //ConnectionHandler.BuildPacket(buffer, this, server); WorldPacketHandler.HandlePacket(buffer, this, server); socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallBack), socket); } catch (Exception e) { Disconnect(); return; } }
public override void Initialize() { base.Initialize(); base.ConsoleInterface = new WorldConsole(); this.VirtualConsoleInterface = new WorldVirtualConsole(); ConsoleBase.SetTitle("#Stump World Server : " + WorldServer.ServerInformation.Name); this.logger.Info("Initializing Database..."); base.DBAccessor = new DatabaseAccessor(WorldServer.DatabaseConfiguration); base.DBAccessor.RegisterMappingAssembly(System.Reflection.Assembly.GetExecutingAssembly()); base.InitializationManager.Initialize(InitializationPass.Database); base.DBAccessor.Initialize(); this.logger.Info("Opening Database..."); base.DBAccessor.OpenConnection(); DataManager.DefaultDatabase = base.DBAccessor.Database; DataManagerAllocator.Assembly = System.Reflection.Assembly.GetExecutingAssembly(); this.logger.Info("Register Messages..."); MessageReceiver.Initialize(); ProtocolTypeManager.Initialize(); this.logger.Info("Register Packet Handlers..."); this.HandlerManager = Singleton <WorldPacketHandler> .Instance; this.HandlerManager.RegisterAll(System.Reflection.Assembly.GetExecutingAssembly()); this.logger.Info("Register Commands..."); base.CommandManager.RegisterAll(System.Reflection.Assembly.GetExecutingAssembly()); base.InitializationManager.InitializeAll(); base.IsInitialized = true; }
public WorldClient( WorldPacketHandler packetHandler, ILogger <WorldClient> logger, IWorldManager world, AccountService accountService) : base(logger) { this.packetHandler = packetHandler; this.accountService = accountService; this.world = world; this.AttackController = new(this); // TODO :( }
public Server(int port) { Clients = new ConcurrentDictionary <IntPtr, Client>(); Port = port; PacketHandlers = new WorldPacketHandler[256]; ControlMessageHandlers = new ControlMessageHandler[64]; ExpectedConnections = new ConcurrentDictionary <uint, Redirect>(); for (int i = 0; i < 256; ++i) { PacketHandlers[i] = (c, p) => Logger.WarnFormat("Server: Unhandled opcode 0x{0:X2}", p.Opcode); } }
public Server(int port) { Clients = new ConcurrentDictionary <IntPtr, Client>(); Port = port; PacketHandlers = new WorldPacketHandler[256]; ControlMessageHandlers = new ControlMessageHandler[64]; Throttles = new Dictionary <byte, IPacketThrottle>(); ExpectedConnections = new ConcurrentDictionary <uint, Redirect>(); for (int i = 0; i < 256; ++i) { PacketHandlers[i] = (c, p) => GameLog.Warning($"{GetType().Name}: Unhandled opcode 0x{p.Opcode:X2}"); } Task.Run(ProcessOutbound); }
public Server(int port) { Port = port; PacketHandlers = new WorldPacketHandler[256]; ControlMessageHandlers = new ControlMessageHandler[64]; ExpectedConnections = new ConcurrentDictionary<uint, Redirect>(); for (int i = 0; i < 256; ++i) PacketHandlers[i] = (c, p) => Logger.WarnFormat("World: Unhandled opcode 0x{0:X2}", p.Opcode); TcpListener = new TcpListener(IPAddress.Any, port); Logger.InfoFormat("Starting TcpListener: {0}:{1}", IPAddress.Any.ToString(), port); TcpListener.Start(); }
public Server(int port) { Port = port; PacketHandlers = new WorldPacketHandler[256]; ControlMessageHandlers = new ControlMessageHandler[64]; ExpectedConnections = new ConcurrentDictionary <uint, Redirect>(); for (int i = 0; i < 256; ++i) { PacketHandlers[i] = (c, p) => Logger.WarnFormat("World: Unhandled opcode 0x{0:X2}", p.Opcode); } TcpListener = new TcpListener(IPAddress.Any, port); Logger.InfoFormat("Starting TcpListener: {0}:{1}", IPAddress.Any.ToString(), port); TcpListener.Start(); }
public override void Initialize() { base.Initialize(); ConsoleInterface = new WorldConsole(); VirtualConsoleInterface = new WorldVirtualConsole(); ConsoleBase.SetTitle($"#Stump World Server - {Version} : {ServerInformation.Name}"); logger.Info("Initializing Database..."); DBAccessor = new DatabaseAccessor(DatabaseConfiguration); DBAccessor.RegisterMappingAssembly(Assembly.GetExecutingAssembly()); foreach (var plugin in PluginManager.Instance.GetPlugins()) { DBAccessor.RegisterMappingAssembly(plugin.PluginAssembly); } InitializationManager.Initialize(InitializationPass.Database); DBAccessor.Initialize(); logger.Info("Opening Database..."); DBAccessor.OpenConnection(); DataManager.DefaultDatabase = DBAccessor.Database; DataManagerAllocator.Assembly = Assembly.GetExecutingAssembly(); DBAccessor.Database.ExecutingCommand += OnExecutingDBCommand; logger.Info("Register Messages..."); MessageReceiver.Initialize(); ProtocolTypeManager.Initialize(); logger.Info("Register Packet Handlers..."); HandlerManager = WorldPacketHandler.Instance; HandlerManager.RegisterAll(Assembly.GetExecutingAssembly()); logger.Info("Register Commands..."); CommandManager.RegisterAll(Assembly.GetExecutingAssembly()); InitializationManager.InitializeAll(); CommandManager.LoadOrCreateCommandsInfo(CommandsInfoFilePath); IsInitialized = true; }
internal static void Initialize() { if (initialized) { throw new InvalidProgramException(); } initialized = true; System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); Core.LoginComplete += new EventHandler(Core_LoginComplete); Core.Disconnected += new EventHandler(Core_Disconnected); launchData = LaunchData.FromCmdLine(System.Environment.CommandLine); clientThreadId = Thread.CurrentThread.ManagedThreadId; SetInitEvent(); InitLogging(); // TODO: Set security try { culture = CultureInfo.GetCultureInfo(launchData.Culture); } catch (Exception e) { culture = CultureInfo.GetCultureInfo("en-US"); ExceptionDialog.Show(e, "Error creating requested culture."); } Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = true; if (!clientKeys.Load()) { ShowMessageBoxAsync("Unknown Client. Please use the same account and password you specified in launcher.", "Information"); } spellList = new SpellList(); Config.InternalSettings.Path = Path.Combine(launchData.PhoenixDir, SettingsFile); Config.Init(); Config.Profile.ProfileChanged += new EventHandler(Profile_ProfileChanged); guiThread = new PhoenixGuiThread(); // Run DataFiles.Load in different thread. Thread loadDataFilesThread = new Thread(new ParameterizedThreadStart(DataFiles.Load)); loadDataFilesThread.Start(launchData.UltimaDir); Phoenix.Logging.JournalHandler.Init(); Notepad.Init(); Phoenix.Runtime.ReportViewer.Init(); Journal.Init(); WorldPacketHandler.Init(); Aliases.Init(); LoginInfo.Init(); UIManager.Init(); SpeechColorOverride.Init(); Phoenix.Runtime.ClientMessageHandler.Init(); Phoenix.Runtime.RuntimeCore.Hotkeys.Init(); LatencyMeasurement.Init(); // Create scripts and plugins dir if doesn't exists DirectoryInfo scriptsDir = new DirectoryInfo(Phoenix.Runtime.RuntimeCore.ScriptsDirectory); if (!scriptsDir.Exists) { scriptsDir.Create(); } DirectoryInfo pluginsDir = new DirectoryInfo(Phoenix.Runtime.RuntimeCore.PluginsDirectory); if (!pluginsDir.Exists) { pluginsDir.Create(); } Core.RegisterServerMessageCallback(0xA9, new MessageCallback(OnCharacterList), CallbackPriority.Highest); Core.RegisterServerMessageCallback(0x1B, new MessageCallback(OnLoginConfirmedPacket), CallbackPriority.Normal); Core.RegisterServerMessageCallback(0x55, new MessageCallback(OnLoginCompletePacket), CallbackPriority.Highest); loadDataFilesThread.Join(); PlayerSkills.Init(); Config.Profile.FpsLimit.Changed += new EventHandler(FrameLimit_Changed); Config.InternalSettings.Load(); Config.Profile.LoadDefault(); Phoenix.Runtime.RuntimeCore.RegisterPhoenix(); Phoenix.Runtime.RuntimeCore.ReloadPlugins(); Phoenix.Runtime.RuntimeCore.CompileScripts(true); Trace.WriteLine("Phoenix initialized.", DateTime.Now.ToString()); }