Esempio n. 1
0
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure to leave the class room", "VCES - Leave confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (tcpClientForStudent.Connected)
                {
                    Data data = new Data();
                    data.cmd      = Command.Leave;
                    data.userName = lblUser.Text;
                    byte[] outStream = data.ToByte();
                    serverStream.Write(outStream, 0, outStream.Length);
                    serverStream.Flush();
                    tcpClientForStudent.Close();
                    udpAudioReceiving.Close();
                }

                sin = new SignIn();
                sin.txtVCESName.Text = lblUser.Text;

                this.Dispose();
                sin.Show();
                sin.txtPassword.Focus();
            }
        }
Esempio n. 2
0
        private void btnJoinLeave_Click(object sender, EventArgs e)
        {
            if (btnJoinLeave.Text.Equals("Join"))
            {
                btnJoinLeave.Enabled = false;
                if (!connectToServer())
                {
                    if (MessageBox.Show("Server User is not online right now!", "Server not responding", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                    {
                        btnJoinLeave_Click(sender, e);
                        return;
                    }
                    else
                    {
                        btnJoinLeave.Enabled = true;
                        return;
                    }
                }

                Thread text = new Thread(messageReceived);
                text.Start();



                Data data = new Data();
                data.cmd      = Command.Join;
                data.userName = lblUser.Text;

                byte[] outStream = data.ToByte();

                serverStream.Write(outStream, 0, outStream.Length);
                serverStream.Flush();

                btnJoinLeave.Text          = "Leave";
                btnJoinLeave.Enabled       = true;
                btnQuestionRequest.Enabled = true;
                btnSend.Enabled            = true;
            }
            else if (btnJoinLeave.Text.Equals("Leave"))
            {
                if (MessageBox.Show("Are you sure to leave the  room", "Leave confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (tcpClientForStudent.Connected)
                    {
                        Data data = new Data();
                        data.cmd      = Command.Leave;
                        data.userName = lblUser.Text;
                        byte[] outStream = data.ToByte();
                        serverStream.Write(outStream, 0, outStream.Length);
                        serverStream.Flush();
                        tcpClientForStudent.Close();
                        udpAudioReceiving.Close();
                    }

                    sin = new SignIn();
                    sin.txtVCESName.Text = lblUser.Text;

                    this.Dispose();
                    this.Hide();
                    sin.Show();
                    sin.txtPassword.Focus();
                }
            }
        }