Ejemplo n.º 1
0
 private void updateTbMess(SocketData data)
 {
     tbMess.Text += data.Message + System.Environment.NewLine;
 }
Ejemplo n.º 2
0
        private void processData(SocketData data)
        {
            if (data != null)
            {
                switch (data.Command)
                {
                case (int)SocketCommand.NOTIFY:
                    MessageBox.Show(data.Message);
                    break;

                case (int)SocketCommand.NEW_GAME:
                    socket.close(socket);

                    /* newGame();
                     * pnChessBoard.Enabled = false;*/
                    this.Invoke((MethodInvoker)(() =>
                    {
                        createPlayer();
                    }));


                    break;

                case (int)SocketCommand.SEND_POINT:
                    this.Invoke((MethodInvoker)(() =>
                    {
                        pgbCoolDown.Value = 0;
                        pnChessBoard.Enabled = true;
                        tmCoolDown.Start();
                        tick = 0;
                        chessBoard.otherPlayerMark(data.Point);
                    }));
                    break;

                case (int)SocketCommand.SEND_MESSAGE:
                    updateTbMess(data);
                    break;

                case (int)SocketCommand.END_GAME:

                    processLost();

                    break;

                case (int)SocketCommand.TIME_OUT:
                    MessageBox.Show("Hết giờ");
                    break;

                case (int)SocketCommand.PLAY1:
                    chessBoard.Player[1].Name = data.Message;
                    chessBoard.Player[0].Name = tbPlayer.Text;

                    //  MessageBox.Show(chessBoard.Player[0].Name + chessBoard.Player[1].Name);
                    break;

                case (int)SocketCommand.PLAY2:
                    chessBoard.Player[0].Name = data.Message;
                    chessBoard.Player[1].Name = tbPlayer.Text;

                    //  MessageBox.Show(chessBoard.Player[0].Name + chessBoard.Player[1].Name);
                    break;

                case (int)SocketCommand.QUIT:
                    tmCoolDown.Stop();
                    MessageBox.Show("Người chơi đã thoát");
                    break;

                default: break;
                }
            }
            listen();
        }