Example #1
0
 void PingHandler()
 {
     new Thread(() =>
     {
         while (!Disposed)
         {
             try
             {
                 if (DequeuePing(out Packet pingpacket))
                 {
                     Peer peer = GetPeer(pingpacket.EndPoint);
                     if (peer == null)
                     {
                         peer = CreatePeer(pingpacket);
                     }
                     peer.EndPoint = pingpacket.EndPoint;
                     peer.RenewLastUpdate();
                     peer.SendRaw(pingpacket.Data);
                 }
                 else
                 {
                     Begin.Reset(); Begin.WaitOne();
                 }
             }
             catch (Exception e)
             {
                 OnException(e);
             }
         }
         Console.WriteLine("Ping manager disposed");
     }).Start();
 }