Beispiel #1
0
        static void InitRoutine()
        {
            //      Extractor.ExtractMonsters();
            AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(App_ThreadException);
            AppDomain.CurrentDomain.ProcessExit        += new System.EventHandler(domain_ProcessExit);

            Console.WriteLine("Server " + "Loading " + Config.ServerName + "...");
            ClientHandler  = new Server();
            IOThread       = new IOThread();
            WebServer      = new WebSocketListener();
            playerHandler  = PlayerHandler.getSingleton();
            world          = World.getSingleton();
            world.handler  = playerHandler;
            World.w_server = ClientHandler;
            //        instanceManager = InstanceManager.getSingleton();
            Map.Init();

            /*  Task.Factory.StartNew(() =>
             *    {
             *        IOThread.run();
             *    });*/
            (new Thread(IOThread.run)).Start();
            (new Thread(ClientHandler.run)).Start();
            (new Thread(WebServer.run)).Start();
            int  waitFails = 0;
            long lastTicks = CurrentTimeMillis();
            long totalTimeSpentProcessing = 0;
            int  cycle = 0;

#if DEBUG
            if (!s_bDoDebugOnlyCode)
            {
                while (!shutdownServer)
                {
                    // playerHandler.process();
                    //EventManager.getSingleton().shutdown();
                    //        instanceManager.process();
                    long timeSpent = CurrentTimeMillis() - lastTicks;
                    totalTimeSpentProcessing += timeSpent;
                    if (timeSpent >= Config.CycleTime)
                    {
                        timeSpent = Config.CycleTime;
                        //   if (++waitFails > 100)
                        //shutdownServer = true;
                    }

                    try
                    {
                        Thread.Sleep((int)(Config.CycleTime - timeSpent));
                    }
                    catch { }

                    lastTicks = CurrentTimeMillis();
                    cycle++;
                    if (cycle % 100 == 0)
                    {
                        //@SuppressWarnings("unused")
                        float time = ((float)totalTimeSpentProcessing) / cycle;
                        Console.WriteLine("KERNEL", ((time * 100) / Config.CycleTime) + "% processing time");
                    }
                }

                //    playerHandler.destruct();
                ClientHandler.killServer();
                ClientHandler = null;
            }
#endif
        }
Beispiel #2
0
 public WebClient(IWebSocketConnection client, WebSocketListener cws_listener)
 {
     iweb = client;
     this.cws_listener = cws_listener;
 }
Beispiel #3
0
        static void InitRoutine()
        {
            //      Extractor.ExtractMonsters();
            AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(App_ThreadException);
            AppDomain.CurrentDomain.ProcessExit += new System.EventHandler(domain_ProcessExit);

            Console.WriteLine("Server " + "Loading " + Config.ServerName + "...");
            ClientHandler = new Server();
            IOThread = new IOThread();
            WebServer = new WebSocketListener();
            playerHandler = PlayerHandler.getSingleton();
            world = World.getSingleton();
            world.handler = playerHandler;
            World.w_server = ClientHandler;
            //        instanceManager = InstanceManager.getSingleton();
            Map.Init();
              /*  Task.Factory.StartNew(() =>
                {
                    IOThread.run();
                });*/
            (new Thread(IOThread.run)).Start();
            (new Thread(ClientHandler.run)).Start();
            (new Thread(WebServer.run)).Start();
            Console.WriteLine("Loading tapping list");
            LKCamelot.model.Modules.NSA.LoadTapList();

            int waitFails = 0;
            long lastTicks = CurrentTimeMillis();
            long totalTimeSpentProcessing = 0;
            int cycle = 0;
            #if DEBUG
            if (!s_bDoDebugOnlyCode)
            {
                while (!shutdownServer)
                {
                   // playerHandler.process();
                    //EventManager.getSingleton().shutdown();
                    //        instanceManager.process();
                    long timeSpent = CurrentTimeMillis() - lastTicks;
                    totalTimeSpentProcessing += timeSpent;
                    if (timeSpent >= Config.CycleTime)
                    {
                        timeSpent = Config.CycleTime;
                     //   if (++waitFails > 100)
                            //shutdownServer = true;
                    }

                    try
                    {
                        Thread.Sleep((int)(Config.CycleTime - timeSpent));
                    }
                    catch { }

                    lastTicks = CurrentTimeMillis();
                    cycle++;
                    if (cycle % 100 == 0)
                    {
                        //@SuppressWarnings("unused")
                        float time = ((float)totalTimeSpentProcessing) / cycle;
                        Console.WriteLine("KERNEL", ((time * 100) / Config.CycleTime) + "% processing time");
                    }
                }

                //    playerHandler.destruct();
                ClientHandler.killServer();
                ClientHandler = null;
            }
            #endif
        }
Beispiel #4
0
 public WebClient(IWebSocketConnection client, WebSocketListener cws_listener)
 {
     iweb = client;
     this.cws_listener = cws_listener;
 }