public IInputHandler GetNetworkPlayer() { SocketHandler socketHandler = clients[counter]; counter++; return(socketHandler); }
public SocketHandler ConnectPlayer() { TcpClient client = tcpListener.AcceptTcpClient(); SocketHandler player = new SocketHandler(client); clients.Add(player); return player; }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; while (socketManager.CountClients < maxClients) { if (worker.CancellationPending) { socketManager.Stop(); e.Cancel = true; break; } if (socketManager.HasIncoming) { SocketHandler player = socketManager.ConnectPlayer(); string playerName = player.WaitForName(); Debug.WriteLine(playerName); } string state = string.Format("Waiting for {0} players..", maxClients - socketManager.CountClients); worker.ReportProgress(socketManager.CountClients * 100 / maxClients, state); Thread.Sleep(10); } }
public SocketHandler ConnectPlayer() { TcpClient client = tcpListener.AcceptTcpClient(); SocketHandler player = new SocketHandler(client); clients.Add(player); return(player); }