public NetState( Socket socket, NetServer netServer ) { m_Socket = socket; m_NetServer = netServer; m_Buffer = new ByteQueue(); m_Running = false; m_RecvBuffer = m_ReceiveBufferPool.AcquireBuffer(); m_SendQueue = new SendQueue(); m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 0.5 ); try { m_Address = ( (IPEndPoint) m_Socket.RemoteEndPoint ).Address; m_ToString = m_Address.ToString(); } catch ( Exception ex ) { TraceException( ex ); m_Address = IPAddress.None; m_ToString = "(error)"; } if ( m_CreatedCallback != null ) m_CreatedCallback( this ); }
public GameServer(NetServer server, PacketHandlers handlers) { m_Server = server; m_Handlers = handlers; }
public static void Run() { EventSink.Instance = new EventSink(); if ( !ScriptCompiler.Compile( Environment.Debug ) ) { Console.WriteLine( "Fatal: Compilation failed. Press any key to exit." ); Console.ReadLine(); return; } ScriptCompiler.VerifyLibraries(); // This instance is shared among timer scheduler and timer executor, // and accessed from both core & timer threads. Queue<Timer> timerQueue = new Queue<Timer>(); // Timer scheduler must be set up before world load, since world load // could schedule timers on entity deserialization. var timerScheduler = TimerScheduler.Instance = new TimerScheduler( timerQueue ); m_TimerThread = new TimerThread( timerScheduler ); TimerExecutor timerExecutor = new TimerExecutor( timerQueue ); PacketHandlers.Instance = new PacketHandlers(); try { ScriptCompiler.Configure(); TileData.Configure(); } catch ( TargetInvocationException e ) { Console.WriteLine( "Fatal: Configure exception: {0}", e.InnerException ); return; } Environment.SaveConfig(); Region.Load(); World.Instance.Load(); try { ScriptCompiler.Initialize(); } catch ( TargetInvocationException e ) { Logger.Error( "Initialize exception: {0}", e.InnerException ); return; } m_TimerThread.Start(); NetServer netServer = new NetServer( new Listener( Listener.Port ) ); netServer.Initialize(); GameServer.Instance = new GameServer( netServer, PacketHandlers.Instance ); GameServer.Instance.Initialize(); EventSink.Instance.InvokeServerStarted(); PacketDispatcher.Initialize(); m_Now = DateTime.UtcNow; m_TotalProfile = new MainProfile( m_Now ); m_CurrentProfile = new MainProfile( m_Now ); try { while ( !m_Closing ) { m_Now = DateTime.UtcNow; Thread.Sleep( 1 ); ClockProfile( MainProfile.TimerId.Idle ); Mobile.ProcessDeltaQueue(); ClockProfile( MainProfile.TimerId.MobileDelta ); Item.ProcessDeltaQueue(); ClockProfile( MainProfile.TimerId.ItemDelta ); timerExecutor.Slice(); ClockProfile( MainProfile.TimerId.Timers ); netServer.Slice(); ClockProfile( MainProfile.TimerId.Network ); // Done with this iteration. m_TotalProfile.Next(); m_CurrentProfile.Next(); } } catch ( Exception e ) { HandleCrashed( e ); } m_TimerThread.Stop(); }
public GameServer(NetServer server) { m_Server = server; }
public GameServer( NetServer server, PacketHandlers handlers ) { m_Server = server; m_Handlers = handlers; }