コード例 #1
0
ファイル: WondersServer.cs プロジェクト: sunneh/7Wonders
        //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
ファイル: PlayerThreadData.cs プロジェクト: sunneh/7Wonders
 public PlayerThreadData(PlayerComm c, Thread pt)
 {
     comm = c;
     playerThread = pt;
 }
コード例 #4
0
 public PlayerThreadData(PlayerComm c, Thread pt)
 {
     comm         = c;
     playerThread = pt;
 }