summaryrefslogtreecommitdiff
path: root/server/lobby.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-11-15 08:24:55 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-11-15 08:24:55 +0100
commitc6a83f89ea55ba2071611513ac85b64134ac8f7b (patch)
treeecb2b4380931da4404d0af927f6645dcc51e81a9 /server/lobby.cpp
parent5c664afc0a91654ec2bd0be1e67995e7f61d27c7 (diff)
Added Player class.
Diffstat (limited to 'server/lobby.cpp')
-rw-r--r--server/lobby.cpp28
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) {