示例#1
0
void Client::run() {
  if (!m_is_connected) {
    ERR("No connection established to Server");
    throw ClientException();
  }

  // receive Server's hello
  bool is_stopped = false;
  Response response = getResponse(m_socket, &is_stopped);
  if (response.isEmpty()) {
    ERR("Received empty response. Connection closed");
    throw ClientException();
  } else {
    std::string system = "", payload = "";
    Path action = Path::UNKNOWN;
    ID_t id = UNKNOWN_ID;
    if (util::checkSystemMessage(response.body, &system, &payload, action, id)) {
      processSystemPayload(payload);
    } else {
      ERR("Incoming response is not a Server's hello!");
      throw ClientException();
    }
  }

  goToMainMenu();
}
void InstructionsScene::onKeyPressed(EventKeyboard::KeyCode keyCode, Event *event) {
	_pressedKey = keyCode;

	switch (_pressedKey) {
		case EventKeyboard::KeyCode::KEY_R:
			goToMainMenu(this);
			break;
	}
}