blob: 667d6eae2f5fd4be8aad0974c9de941ab3aceeac (
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
41
42
43
44
45
46
47
48
|
#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 <boost/asio.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::asio::deadline_timer timer;
boost::function<void (Player::p)> lobby_callback;
boost::function<void ()> ready_callback;
std::string nick_;
Player(Connection::p c, boost::function<void (Player::p)> f);
//! Start communicating.
void start();
//! Handle Login-message.
void handle_login(Message::p msg);
//! Handle Ready-message.
void handle_ready(Message::p msg);
public:
//! Return player's nick.
std::string nick();
//! Notify client of a game start.
void game_start(boost::function<void ()> callback, std::vector<Player::p> players);
};
#endif
|