示例#1
0
 private static void ServerListenerThreadRun()
 {
     //MessageBox.Show("Listener thread started.");
     Listener = new TcpListener(IPAddress.IPv6Any, Port);
     Listener.Start();
     while (true)
     {
         TcpClient client;
         try
         {
             client = Listener.AcceptTcpClient();
         }
         catch (SocketException)
         {
             return;
         }
         Thread t = new Thread(new ParameterizedThreadStart(ThreadPerPlayer));
         PlayerThreads.Add(t);
         t.Start(client);
     }
 }
示例#2
0
 public static void Leave()
 {
     if (ConnectedMatch == null)
     {
         return;
     }
     SyncUpdate(NetUpdateType.Leave, null);
     SendUpdate = false;
     if (ConnectedMatch.OwnerName == Game.Player.Name)
     {
         Listener.Stop();
     }
     ReceiverThread.Abort();
     if (StopEventPerPlayer != null)
     {
         StopEventPerPlayer(null, null);
     }
     foreach (Thread t in PlayerThreads)
     {
         t.Abort();
     }
     PlayerThreads.Clear();
     ConnectedMatch = null;
 }