int main(int argc, char *argv[]) { QApplication a(argc, argv); Welcome w; w.setFixedSize(500,350); w.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); Welcome w; w.show(); return a.exec(); }
void ProcessHello::execute() { ORWELL_LOG_INFO("ProcessHello::execute"); orwell::messages::Hello const & anHelloMsg = static_cast<orwell::messages::Hello const & >(*m_msg); std::string const & aClientID = getArgument("RoutingID"); string aNewPlayerName = anHelloMsg.name(); bool const aPlayerAddedSuccess = m_game->addPlayer( aNewPlayerName ); bool aFailure = not aPlayerAddedSuccess; if (aPlayerAddedSuccess) { std::shared_ptr< ::orwell::game::Robot > aAvailableRobot = m_game->getRobotForPlayer(aNewPlayerName); aFailure = true; if (aAvailableRobot.get() != nullptr) { ORWELL_LOG_INFO( "Player " << aNewPlayerName << " is now linked to robot " << aAvailableRobot->getName() ); std::shared_ptr< game::Player > aPlayer = m_game->accessPlayer(aNewPlayerName); if (nullptr != aPlayer) { aPlayer->setRobot(aAvailableRobot); aAvailableRobot->setPlayer(aPlayer); Welcome aWelcome; aWelcome.set_robot(aAvailableRobot->getName()); aWelcome.set_team("team_red"); //currently stupidly hard coded aWelcome.set_id(aAvailableRobot->getRobotId()); aWelcome.set_video_address("localhost"); aWelcome.set_video_port(aAvailableRobot->getVideoRetransmissionPort()); RawMessage aReply(aClientID, "Welcome", aWelcome.SerializeAsString()); m_publisher->send(aReply); aFailure = false; if (m_game->getAvailableRobot() == nullptr) { m_game->start(); } } else { // there is no reason for the player not to be found // but we consider Goodbye would be sent. } } else { ORWELL_LOG_INFO("No robot available for player (" << aNewPlayerName << ")"); } } if (aFailure) { ORWELL_LOG_WARN( "Impossible to process Hello ; player added with success :" << aPlayerAddedSuccess); Goodbye aGoodbye; RawMessage aReply(aClientID, "Goodbye", aGoodbye.SerializeAsString()); m_publisher->send(aReply); } }