//listens for new connections and creates a new thread to handle communication private void listenForPlayers(){ PlayerComm playComm; Thread playerThread; listenSocket.Start(); //PlayerThreadData tp; do { if (mQueue.isStarted()) return; player = listenSocket.AcceptTcpClient(); int playerNum = mQueue.addPlayer(); if (playerNum < 0) { player.GetStream().Write(full, 0, full.Length); continue; } playComm = new PlayerComm(player, mQueue, messageSize, playerNum); mQueue.subscribe(playComm); //mQueue.notifyAll(); playerThread = new Thread(new ThreadStart(playComm.handlePlayer)); playerThread.Start(); playersList[mQueue.getPlayers() - 1] = new PlayerThreadData(playComm, playerThread); /* tp = new ToPass(player, mQueue); Thread playerThread = new Thread(new ParameterizedThreadStart(handlePlayer)); playerThread.Start(tp); */ } while (true); }
//listens for new connections and creates a new thread to handle communication private void listenForPlayers() { PlayerComm playComm; Thread playerThread; listenSocket.Start(); //PlayerThreadData tp; do { if (mQueue.isStarted()) { return; } player = listenSocket.AcceptTcpClient(); int playerNum = mQueue.addPlayer(); if (playerNum < 0) { player.GetStream().Write(full, 0, full.Length); continue; } playComm = new PlayerComm(player, mQueue, messageSize, playerNum); mQueue.subscribe(playComm); //mQueue.notifyAll(); playerThread = new Thread(new ThreadStart(playComm.handlePlayer)); playerThread.Start(); playersList[mQueue.getPlayers() - 1] = new PlayerThreadData(playComm, playerThread); /* * tp = new ToPass(player, mQueue); * Thread playerThread = new Thread(new ParameterizedThreadStart(handlePlayer)); * playerThread.Start(tp); */ } while (true); }
public PlayerThreadData(PlayerComm c, Thread pt) { comm = c; playerThread = pt; }