#include "lobby.h" #include #include #include "game.h" void Lobby::handle_connect(Connection::p connection) { // Create player. Client::create(connection, boost::bind(&Lobby::handle_action, this, _1)); // Get another connection. server.get_connection(boost::bind(&Lobby::handle_connect, this, _1)); } void Lobby::handle_action(Client::p client) { std::cout << "Client " << client->nick() << " entered the lobby." << std::endl; if(waiting.size() >= 3) { Game::create(waiting[0], waiting[1], waiting[2], client); waiting.clear(); } else { waiting.push_back(client); } } Lobby::Lobby() : server(io_service) { } void Lobby::run() { // Get a connection. server.get_connection(boost::bind(&Lobby::handle_connect, this, _1)); io_service.run(); }