public void unlockWaitingUser(UInt32 userId) { for (int i = 0; i < clientList.Count; i++) { MarginClient temp = (MarginClient)clientList[i]; if (temp.isYourClientWaiting(userId)) { break; } } }
public void removeClientsByCharId(UInt32 charId) { MarginClient removeClient = null; foreach (MarginClient resultClient in clientList) { if (resultClient.getCharID() == charId) { removeClient = resultClient; break; } } clientList.Remove(removeClient); }
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); } }
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(); }
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); } }