public ServerInfo(LevelManager levelManager, ConcurrentDictionary<IPEndPoint, PlayerNetworkSession> playerSessions) { _levelManager = levelManager; PlayerSessions = playerSessions; { ThroughPut = new Timer(delegate(object state) { NumberOfPlayers = PlayerSessions.Count; int threads; int portThreads; ThreadPool.GetAvailableThreads(out threads, out portThreads); double kbitPerSecondOut = TotalPacketSizeOut*8/1000000D; double kbitPerSecondIn = TotalPacketSizeIn*8/1000000D; if (Log.IsInfoEnabled) { Log.InfoFormat("TT {4:00}ms Ly {6:00}ms {5} Pl(s) Pkt(#/s) ({0} {2}) ACK/NAK(#/s) {1}/{11} Tput(Mbit/s) ({3:F} {7:F}) Avail {8}kb Threads {9} Compl.ports {10}", NumberOfPacketsOutPerSecond, NumberOfAckSent, NumberOfPacketsInPerSecond, kbitPerSecondOut, 0 /*_level.LastTickProcessingTime*/, NumberOfPlayers, Latency, kbitPerSecondIn, AvailableBytes/1000, threads, portThreads, NumberOfNakReceive); } else if (AvailableBytes != 0) { Log.WarnFormat("Socket buffering, avail: {0}", AvailableBytes); } NumberOfAckReceive = 0; NumberOfNakReceive = 0; NumberOfAckSent = 0; TotalPacketSizeOut = 0; TotalPacketSizeIn = 0; NumberOfPacketsOutPerSecond = 0; NumberOfPacketsInPerSecond = 0; NumberOfDeniedConnectionRequestsPerSecond = 0; }, null, 1000, 1000); } }
public ServerInfo(LevelManager levelManager, ConcurrentDictionary<IPEndPoint, PlayerNetworkSession> playerSessions) { _levelManager = levelManager; PlayerSessions = playerSessions; { ThroughPut = new Timer(delegate (object state) { NumberOfPlayers = PlayerSessions.Count; int threads; int portThreads; ThreadPool.GetAvailableThreads(out threads, out portThreads); double kbitPerSecondOut = Interlocked.Exchange(ref TotalPacketSizeOut, 0) * 8/1000000D; double kbitPerSecondIn = Interlocked.Exchange(ref TotalPacketSizeIn, 0) * 8/1000000D; Log.WarnFormat("TT {4:00}ms Ly {6:00}ms {5} Pl(s) Pkt(#/s) (Out={0} In={2}) ACK/NAK/RESD/FTO(#/s) {1}/{11}/{12}/{13} Tput(Mbit/s) ({3:F} {7:F}) Avail {8}kb Threads {9} Compl.ports {10}", Interlocked.Exchange(ref NumberOfPacketsOutPerSecond, 0), Interlocked.Exchange(ref NumberOfAckReceive, 0), Interlocked.Exchange(ref NumberOfPacketsInPerSecond, 0), kbitPerSecondOut, 0 /*_level.LastTickProcessingTime*/, NumberOfPlayers, Latency, kbitPerSecondIn, AvailableBytes / 1000, threads, portThreads, Interlocked.Exchange(ref NumberOfNakReceive, 0), Interlocked.Exchange(ref NumberOfResends, 0), Interlocked.Exchange(ref NumberOfFails, 0)); //Interlocked.Exchange(ref NumberOfAckReceive, 0); //Interlocked.Exchange(ref NumberOfNakReceive, 0); Interlocked.Exchange(ref NumberOfAckSent, 0); //Interlocked.Exchange(ref TotalPacketSizeOut, 0); //Interlocked.Exchange(ref TotalPacketSizeIn, 0); //Interlocked.Exchange(ref NumberOfPacketsOutPerSecond, 0); //Interlocked.Exchange(ref NumberOfPacketsInPerSecond, 0); Interlocked.Exchange(ref NumberOfDeniedConnectionRequestsPerSecond, 0); //Interlocked.Exchange(ref NumberOfFails, 0); //Interlocked.Exchange(ref NumberOfResends, 0); }, null, 1000, 1000); } }
public ServerInfo(LevelManager levelManager, ConcurrentDictionary<IPEndPoint, PlayerNetworkSession> playerSessions) { _levelManager = levelManager; PlayerSessions = playerSessions; if (Config.GetProperty("EnableStatistics", false)) { ThroughPut = new Timer(delegate(object state) { NumberOfPlayers = PlayerSessions.Count; int threads; int portThreads; ThreadPool.GetAvailableThreads(out threads, out portThreads); double kbitPerSecondOut = TotalPacketSizeOut*8/1000000D; double kbitPerSecondIn = TotalPacketSizeIn*8/1000000D; Log.InfoFormat("TT {4:00}ms Ly {6:00}ms {5} Pl(s) Pkt(#/s) ({0} {2}) ACKs {1}/s Tput(Mbit/s) ({3:F} {7:F}) Avail {8}kb Threads {9} Compl.ports {10} {11} {12}", NumberOfPacketsOutPerSecond, NumberOfAckSent, NumberOfPacketsInPerSecond, kbitPerSecondOut, 0 /*_level.LastTickProcessingTime*/, NumberOfPlayers, Latency, kbitPerSecondIn, AvailableBytes/1000, threads, portThreads, NumberOfAckReceive, NumberOfNakReceive); NumberOfAckReceive = 0; NumberOfNakReceive = 0; NumberOfAckSent = 0; TotalPacketSizeOut = 0; TotalPacketSizeIn = 0; NumberOfPacketsOutPerSecond = 0; NumberOfPacketsInPerSecond = 0; }, null, 1000, 1000); } }
public bool StartServer() { DisplayTimerProperties(); if (_listener != null) { return(false); // Already started } try { Log.Info("Initializing..."); if (ServerRole == ServerRole.Full || ServerRole == ServerRole.Proxy) { if (IsEdu) { EduTokenManager = new EduTokenManager(); } if (Endpoint == null) { var ip = IPAddress.Parse(Config.GetProperty("ip", "0.0.0.0")); int port = Config.GetProperty("port", 19132); Endpoint = new IPEndPoint(ip, port); } } ServerManager = ServerManager ?? new DefaultServerManager(this); if (ServerRole == ServerRole.Full || ServerRole == ServerRole.Node) { Log.Info("Loading plugins..."); PluginManager = new PluginManager(); PluginManager.LoadPlugins(); Log.Info("Plugins loaded!"); // Bootstrap server PluginManager.ExecuteStartup(this); GreylistManager = GreylistManager ?? new GreylistManager(this); SessionManager = SessionManager ?? new SessionManager(); LevelManager = LevelManager ?? new LevelManager(); //LevelManager = LevelManager ?? new SpreadLevelManager(1); PlayerFactory = PlayerFactory ?? new PlayerFactory(); PluginManager.EnablePlugins(this, LevelManager); // Cache - remove LevelManager.GetLevel(null, Dimension.Overworld.ToString()); } GreylistManager = GreylistManager ?? new GreylistManager(this); MotdProvider = MotdProvider ?? new MotdProvider(); if (ServerRole == ServerRole.Full || ServerRole == ServerRole.Proxy) { _listener = CreateListener(); new Thread(ProcessDatagrams) { IsBackground = true }.Start(_listener); } ServerInfo = new ServerInfo(LevelManager, _playerSessions) { MaxNumberOfPlayers = Config.GetProperty("MaxNumberOfPlayers", 1000) }; ServerInfo.MaxNumberOfConcurrentConnects = Config.GetProperty("MaxNumberOfConcurrentConnects", ServerInfo.MaxNumberOfPlayers); _tickerHighPrecisionTimer = new HighPrecisionTimer(10, SendTick, true); Log.Info("Server open for business on port " + Endpoint?.Port + " ..."); return(true); } catch (Exception e) { Log.Error("Error during startup!", e); StopServer(); } return(false); }