Exemple #1
0
        //Hàm xử lý bên nhận
        public void ProcessData(SocketData data)
        {
            switch (data.Command)
            {
            case (int)SocketCommand.SEND_DATA:
                this.Invoke((MethodInvoker)(() =>
                {
                    lbInfoClient.Hide();
                    lbInfoServer.Hide();
                    DrawInfoSend(player, data);
                    action.DrawBlockSend(data.Name, data.Block, pnlServerInClient, pnlClientInServer);
                    action.UpdatePanelAfterReceive(data.Name, data.Board, pnlServer, pnlClient);
                }));
                break;

            case (int)SocketCommand.NEW_GAME:
                this.Invoke((MethodInvoker)(() =>
                {
                    NewGame();
                }));
                break;

            case (int)SocketCommand.PAUSE:
                this.Invoke((MethodInvoker)(() =>
                {
                    Pause();
                }));
                break;

            case (int)SocketCommand.QUIT:
                timer1.Enabled = false;
                MessageBox.Show("Người chơi cùng đã thoát");
                break;

            case (int)SocketCommand.END_GAME:
                timer1.Enabled     = false;
                timerWatch.Enabled = false;
                MessageBox.Show("Người chơi cùng đã thua .Kết thúc game.");
                break;

            case (int)SocketCommand.MODETIME:
                this.Invoke((MethodInvoker)(() =>
                {
                    ModeTime();
                    timerWatch.Enabled = true;
                }));
                break;

            case (int)SocketCommand.MODECLASSIC:
                this.Invoke((MethodInvoker)(() =>
                {
                    ModeClassic();
                }));
                break;

            case (int)SocketCommand.MESSENGER:
                this.Invoke((MethodInvoker)(() =>
                {
                    Messenger(data.Messenger);
                }));
                break;
            }
            Listen();
        }