Пример #1
0
 public void unlockWaitingUser(UInt32 userId)
 {
     for (int i = 0; i < clientList.Count; i++)
     {
         MarginClient temp = (MarginClient)clientList[i];
         if (temp.isYourClientWaiting(userId))
         {
             break;
         }
     }
 }
Пример #2
0
        public void removeClientsByCharId(UInt32 charId)
        {
            MarginClient removeClient = null;

            foreach (MarginClient resultClient in clientList)
            {
                if (resultClient.getCharID() == charId)
                {
                    removeClient = resultClient;
                    break;
                }
            }
            clientList.Remove(removeClient);
        }
Пример #3
0
        private void ListenForClients()
        {
            this.tcpListener.Start();

            while (mainThreadWorking)
            {
                // Create a new object when a client arrives
                TcpClient    client    = this.tcpListener.AcceptTcpClient();
                MarginClient marClient = new MarginClient(client.GetHashCode());

                // Add it to the Margin clients list
                clientList.Add(marClient);

                // Define a new thread with the handling method as main loop and start it
                Thread clientThread = new Thread(new ParameterizedThreadStart(marClient.HandleClientComm));
                threadList.Add(clientThread);

                clientThread.Start(client);
            }
        }
Пример #4
0
        public void stopServer()
        {
            this.mainThreadWorking = false;
            for (int i = 0; i < clientList.Count; i++)
            {
                MarginClient temp = (MarginClient)clientList[i];
                temp.forceClose();
            }

            this.tcpListener.Stop();
            for (int i = 0; i < threadList.Count; i++)
            {
                Thread tempThread = (Thread)threadList[i];
                if (tempThread.IsAlive)
                {
                    Output.WriteLine("Margin thread " + i + " is alive, closing it");
                    tempThread.Abort();
                }
            }

            this.listenThread.Abort();
        }
Пример #5
0
        private void ListenForClients()
        {
            this.tcpListener.Start();

              			while (mainThreadWorking){
                // Create a new object when a client arrives
                TcpClient client = this.tcpListener.AcceptTcpClient();
                MarginClient marClient = new MarginClient(client.GetHashCode());

                // Add it to the Margin clients list
                clientList.Add(marClient);

                // Define a new thread with the handling method as main loop and start it
                Thread clientThread = new Thread(new ParameterizedThreadStart(marClient.HandleClientComm));
                threadList.Add(clientThread);

                clientThread.Start(client);
              			}
        }