diff options
Diffstat (limited to 'server/lobby.cpp')
-rw-r--r-- | server/lobby.cpp | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/server/lobby.cpp b/server/lobby.cpp index f74a4f2..a3b50d7 100644 --- a/server/lobby.cpp +++ b/server/lobby.cpp @@ -5,35 +5,15 @@ #include <iostream> void Lobby::handle_connect(Connection::p connection) { - // Send Hello. - connection->send(make_shared<Message::Hello>("aotenjoud git")); - - // Wait for Login. - connection->recv(boost::bind(&Lobby::handle_login, this, connection, _1)); + // Create player. + Player::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_login(Connection::p connection, Message::p msg) { - if(msg->type != Message::Types::Login) { - return; - } - - Message::Login::p login_msg = dynamic_pointer_cast<Message::Login>(msg); - - std::cout << "Player " << login_msg->nick << " entered the lobby." << std::endl; - - // Check if nick is invalid. - if(login_msg->nick.size() == 0) { - connection->send(make_shared<Message::LoginResponse>(false)); - connection->recv(boost::bind(&Lobby::handle_login, this, connection, _1)); - return; - } - - connection->send(make_shared<Message::LoginResponse>(true)); - - // Do something with the connection to keep it around. +void Lobby::handle_action(Player::p player) { + std::cout << "Player " << player->nick() << " entered the lobby." << std::endl; } Lobby::Lobby() : server(io_service) { |