예제 #1
0
        //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);
        }
예제 #2
0
        //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);
        }
예제 #3
0
 public PlayerThreadData(PlayerComm c, Thread pt)
 {
     comm = c;
     playerThread = pt;
 }
예제 #4
0
 public PlayerThreadData(PlayerComm c, Thread pt)
 {
     comm         = c;
     playerThread = pt;
 }