public void AddPing(PingReplyWrapper reply, PingInfo info = null)
        {
            var result = reply != null && reply.Status == System.Net.NetworkInformation.IPStatus.Success
                ? reply.RoundtripTime
                : (long?)null;

            IsNetworkAccessible = result != null;
            if (info == null)
            {
                info = new PingInfo {
                    Time = DateTime.Now
                };
            }
            lock (Pings.GetLock())
            {
                Pings.Add(info);
            }
            info.Roundtrip = result;
            List <PingInfo> lastPings;

            lock (Pings.GetLock())
            {
                lastPings = Pings.Where(p => p.Time > DateTime.Now - Config.Instance.PingGraphTimeSize).ToList();
            }
            var lastPingsSuccess = lastPings.Where(p => p.Roundtrip != null).ToList();

            NetworkAvailability = 100.0 * lastPingsSuccess.Count / lastPings.Count;
            NetworkAvgRoundtrip = lastPingsSuccess.Count == 0
                ? 0
                : (long)lastPingsSuccess.Average(p => p.Roundtrip.Value);
        }
 public virtual void StopSW()
 {
     _stopWatch.Stop();
     if (_stopWatch.ElapsedMilliseconds > 0)
     {
         Pings.Add(_stopWatch.ElapsedMilliseconds);
     }
     _stopWatch.Reset();
 }
 public void ProcessParser(IServerQueryParser parser)
 {
     if (Pings.Count == 0)
     {
         Pings.Add(Common.MagicPingValue);
     }
     Result          = parser.ParsePackets(this);
     ReceivedPackets = null;
     Succeed();
 }
        public void Decode(NetIncomingMessage im)
        {
            var count = im.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var guid = Guid.Parse(im.ReadString());
                var ping = im.ReadInt32();

                Pings.Add(guid, ping);
            }
        }