Exemplo n.º 1
0
 void BeginListen()
 {
     new Thread(() => {
         while (!Disposed)
         {
             try
             {
                 Packet packet = Receive(ref EndPoint);
                 if (PingManager.IsPingPacket(packet))
                 {
                     PingManager.EnqueuePing(packet);
                 }
                 else if (PacketManager.IsValidPacket(packet))
                 {
                     PacketManager.EnqueuePacket(packet);
                 }
             }
             catch (ObjectDisposedException) {}
             catch (SocketException) {}
             catch (Exception e)
             {
                 Console.WriteLine(e);
             }
         }
         Console.WriteLine("Listener has stopped");
     }).Start();
 }
Exemplo n.º 2
0
 public override void Dispose()
 {
     Disposed = true;
     base.Dispose();
     Peers.Clear();
     TickManager.Dispose();
     PingManager.Dispose();
     PacketManager.Dispose();
 }
Exemplo n.º 3
0
 protected NuclearServer(int port, int tickrate) : this(new IPEndPoint(IPAddress.Any, port))
 {
     PacketManager = new PacketManager(Workloads, GetPeer, OnException);
     PingManager   = new PingManager(GetPeer, CreatePeer, OnException);
     TickManager   = new TickManager(tickrate, CleanPeers);
     TickManager.AddToTick(HandlePackets);
     TickManager.AddToTick(OnTick);
     EventSender = new EventSender(_client);
     BeginListen();
     SetMaxThreads();
 }