public void Run(string address, int port) { Console.WriteLine("Creating server on " + port + "..."); var server = new TychaiaServer(port, port + 1); server.StartWorld(this.m_Kernel); // Register the local node with Ninject so that entities and worlds can // gain access to it. this.m_Kernel.Bind<INetworkAPI>().ToMethod(x => server); // Create the GameState. Console.WriteLine("Server is now running."); var pingThread = new Thread(() => this.PingServerList(IPAddress.Parse(address), port)) { IsBackground = true }; pingThread.Start(); // Run the game. while (true) { var start = DateTime.Now; server.Update(); var amount = (1000 / 30) - (int)(DateTime.Now - start).TotalMilliseconds; if (amount > 0) { Thread.Sleep(amount); } else { Console.WriteLine("WARNING: Tick took " + (int)(DateTime.Now - start).TotalMilliseconds + "ms, which is longer than 33ms."); } } // ReSharper disable once FunctionNeverReturns }