// answer from server about joining the room public void joinAnswer() { string ans = Helpers.getMessage(1, _clientStream); switch (ans) { case Protocol.JOIN_ROOM_SUCCESS: // joined ! _mf.setIsWaiting(true); _questionsNo = int.Parse(Helpers.getMessage(2, _clientStream)); _time = int.Parse(Helpers.getMessage(2, _clientStream)); promptLabel.Visible = false; _waitWin.initNormal(_questionsNo, _time); _waitWin.initNames(usernameLabel.Text, _roomName); _waitWin.initForJoin(); break; case Protocol.JOIN_ROOM_FULL: // the room is full promptLabel.Visible = true; promptLabel.Text = FULL; break; case Protocol.JOIN_ROOM_OTHER: // failed because of other reason promptLabel.Visible = true; promptLabel.Text = OTHER; break; } }
// called when answer recieved public void answer() { string message = Helpers.getMessage(1, _clientStream); if (message == Protocol.CREATE_ROOM_SUCCESS) { // if room created _waitWin.setStream(_clientStream); _waitWin.initAdmin(int.Parse(_playerNo), int.Parse(_questionNo), int.Parse(_time)); _waitWin.initNames(usernameLabel.Text, _roomName); _waitWin.initName(_username); _waitWin.Visible = true; } else { // if there was an error errorLabel.Visible = true; errorLabel.Text = FAIL; } }