summaryrefslogtreecommitdiff
path: root/server/lobby.cpp
blob: a3b50d786454cbdf0f41d4ccebc73bbb1418a0ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "lobby.h"

#include <boost/bind.hpp>

#include <iostream>

void Lobby::handle_connect(Connection::p connection) {
	// 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_action(Player::p player) {
	std::cout << "Player " << player->nick() << " entered the lobby." << std::endl;
}

Lobby::Lobby() : server(io_service) {
	
}

void Lobby::run() {
	// Get a connection.
	server.get_connection(boost::bind(&Lobby::handle_connect, this, _1));
	
	io_service.run();
}