Esempio n. 1
0
        private void DrawStats(SpriteBatch batch, GameTime gameTime)
        {
            epoc += gameTime.ElapsedGameTime.TotalSeconds;
            if (epoc >= 0.1)
            {
                epoc = 0f;
                var bifrost = _gameServer.LookupSystem<BifrostServer>();
                stats = bifrost.GetStats();

                clientCount = _gameServer.EntityManager.GetEntities(Aspect.One(typeof(PlayerComponent))).Count;
            }
            if (stats == null) return;

            var scale = Matrix.CreateScale(0.5f);
            batch.Begin(transformMatrix: scale);
            batch.DrawString(_font, "In Kbps: " + Math.Round(stats.BytesInPerSec/1024f * 8f,1), new Vector2(1320, 10), Color.Red);
            batch.DrawString(_font, "Out Kbps: " + Math.Round(stats.BytesOutPerSec/ 1024f * 8f, 1), new Vector2(1305, 40), Color.Red);
            batch.DrawString(_font, "Clients: " + clientCount, new Vector2(1320, 70), Color.Red);

            batch.End();
        }
Esempio n. 2
0
        public NetStats GetStats()
        {
            if (Peer == null || Peer.Statistics == null || Peer.Connections.Count == 0)
                return null;

            if (_stats == null)
            {
                _lastNetCheck = (float)Lidgren.Network.NetTime.Now;
                _stats = new NetStats();
                _stats.TotalInBytes = Peer.Statistics.ReceivedBytes;
                _stats.TotalOutBytes = Peer.Statistics.SentBytes;
            }

            var diff = (float)Lidgren.Network.NetTime.Now - _lastNetCheck;

            if (diff > 10f)
            {
                _lastNetCheck = (float)Lidgren.Network.NetTime.Now;
                _stats = new NetStats();
                _stats.TotalInBytes = Peer.Statistics.ReceivedBytes;
                _stats.TotalOutBytes = Peer.Statistics.SentBytes;
                _stats.AvgPing = Peer.Connections[0].AverageRoundtripTime/2f*1000f;
                return _stats;
            }

            _stats.BytesInPerSec = (float)Math.Round((Peer.Statistics.ReceivedBytes - _stats.TotalInBytes) / diff, 2);
            _stats.BytesOutPerSec = (float)Math.Round((Peer.Statistics.SentBytes - _stats.TotalOutBytes) / diff, 2);
            _stats.AvgPing = Peer.Connections[0].AverageRoundtripTime/2f*1000f;
            return _stats;
        }
Esempio n. 3
0
        public NetStats GetStats()
        {
            if (Peer == null || Peer.Statistics == null)
                return null;

            if (_stats == null)
            {
                _lastNetCheck = (float)Lidgren.Network.NetTime.Now;
                _stats = new NetStats();
                _stats.TotalInBytes = Peer.Statistics.ReceivedBytes;
                _stats.TotalOutBytes = Peer.Statistics.SentBytes;
            }

            var diff = (float)Lidgren.Network.NetTime.Now - _lastNetCheck;

            if (diff > 10f)
            {
                _lastNetCheck = (float)Lidgren.Network.NetTime.Now;
                _stats = new NetStats();
                _stats.TotalInBytes = Peer.Statistics.ReceivedBytes;
                _stats.TotalOutBytes = Peer.Statistics.SentBytes;
                return _stats;
            }

            _stats.BytesInPerSec = (float)Math.Round((Peer.Statistics.ReceivedBytes - _stats.TotalInBytes) / diff,2);
            _stats.BytesOutPerSec = (float)Math.Round((Peer.Statistics.SentBytes - _stats.TotalOutBytes) / diff,2);

            return _stats;
        }
Esempio n. 4
0
        private void DrawStats(SpriteBatch batch, GameTime gameTime)
        {
            epoc += gameTime.ElapsedGameTime.TotalSeconds;
            if (epoc >= 0.1)
            {
                epoc = 0f;
                var bifrost = _gameClient.LookupSystem<BifrostClient>();
                stats = bifrost.GetStats();
            }

            if (stats == null) return;

            var scale = Matrix.CreateScale(0.5f);
            batch.Begin(transformMatrix: scale);
            batch.DrawString(_font, "In Kbps: " + Math.Round(stats.BytesInPerSec / 1024f * 8f, 1), new Vector2(1320, 10), Color.Red);
            batch.DrawString(_font, "Out Kbps: " + Math.Round(stats.BytesOutPerSec / 1024f * 8f, 1), new Vector2(1305, 40), Color.Red);
            batch.DrawString(_font, "Ping: " + Math.Round(stats.AvgPing,2) + "ms", new Vector2(1370, 70), Color.Red);

            batch.End();
        }