summaryrefslogtreecommitdiff
path: root/server/player.h
blob: 17e8989ae6282f0490d6299aad8dfa19d514b32b (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
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef PLAYER_H
#define PLAYER_H

#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/function.hpp>

#include "connection.h"

class Player : public boost::enable_shared_from_this<Player> {
	public:
		typedef boost::shared_ptr<Player> p;
		
		static p create(Connection::p c, boost::function<void (Player::p)> f);
	
	private:
		Connection::p connection;
		
		boost::function<void (Player::p)> lobby_callback;
		
		std::string nick_;
		
		Player(Connection::p c, boost::function<void (Player::p)> f);
		
		//! Start communicating.
		void start();
		
		//! Handle login.
		void handle_login(Message::p msg);
		
	public:
		//! Return player's nick.
		std::string nick();
		
		//! Notify client of a game start.
		void game_start();
};

#endif