Exemplo n.º 1
0
        private void sendButton_Click(object sender, EventArgs e)
        {
            string message;

            _roomName   = roomNameTextbox.Text.ToString();
            _playerNo   = playerNumberTextbox.Text.ToString();
            _questionNo = questionNumberTextBox.Text.ToString().PadLeft(2, '0');
            _time       = timeTextbox.Text.ToString().PadLeft(2, '0');

            string roomNameLen = _roomName.Length.ToString().PadLeft(2, '0');    /// get length of room name (in 2 bytes)

            if (_playerNo == "" || _playerNo.Length > 1 || _roomName == "" || _questionNo == "" || _questionNo.Length > 2 || _time == "" || _time.Length > 2)
            {
                errorLabel.Visible = true;
                errorLabel.Text    = FIELDS_ERROR;
            }
            else
            {
                errorLabel.Visible = false;
                message            = Protocol.CREATE_ROOM_SEND + roomNameLen + _roomName + _playerNo + _questionNo + _time;
                Helpers.sendMessage(message, _clientStream);
                _waitWin.Visible = false;
                this.Hide();
                this.Close();
                _waitWin.ShowDialog();
            }
        }
Exemplo n.º 2
0
        // clicked join button - join to this room
        private void joinButton_Click(object sender, EventArgs e)
        {
            // when this button is clicked, we shall send a request to the server - join the room
            if (_currId != "")
            {
                string message = Protocol.JOIN_ROOM_SEND + _currId;
                Helpers.sendMessage(message, _clientStream);

                this.Hide();
                _waitWin.ShowDialog();
                _waitWin.Visible = false;
                this.Close();
            }
        }