summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-12-01 14:04:55 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-12-01 14:04:55 +0100
commit76636ecbb9c6fd312cc450fcb82c4e7a0b67639e (patch)
treee2460faafb1c55bc97c57ade08cd2aae5f16bb6c /server
parent99960dd1580e32423bda5b53ad9c39ebb6b1dbd9 (diff)
Made Client a child of abstract ClientBase.
Diffstat (limited to 'server')
-rw-r--r--server/client.h46
1 files changed, 37 insertions, 9 deletions
diff --git a/server/client.h b/server/client.h
index cbb588f..ed3a47b 100644
--- a/server/client.h
+++ b/server/client.h
@@ -9,7 +9,37 @@
#include "connection.h"
-class Client : public boost::enable_shared_from_this<Client> {
+//! Abstract client base class.
+class ClientBase {
+ public:
+ typedef boost::shared_ptr<ClientBase> p;
+
+ virtual ~ClientBase() {}
+
+ //! Return client's nick.
+ virtual std::string nick() = 0;
+
+ //! Notify client of a game start.
+ virtual void game_start(boost::function<void ()> callback, std::vector<std::string> players) = 0;
+
+ //! Notify client of a round start.
+ virtual void round_start() = 0;
+
+ typedef Message::RoundState::Player PlayerState;
+
+ //! Send round state.
+ virtual void round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a) = 0;
+
+ //! Send round end.
+ virtual void round_end(boost::function<void ()> callback) = 0;
+
+ //! Get action. Upon connection error, last element of expected_actions will be provided.
+ virtual void get_action(boost::function<void (Action)> callback, Actions expected_actions) = 0;
+
+};
+
+//! Class implementing ClientBase for real clients.
+class Client : public ClientBase, public boost::enable_shared_from_this<Client> {
public:
typedef boost::shared_ptr<Client> p;
@@ -44,24 +74,22 @@ class Client : public boost::enable_shared_from_this<Client> {
void lobby_status(const std::vector<std::string>& game_modes, boost::function<void (int)> callback);
//! Return client's nick.
- std::string nick();
+ virtual std::string nick();
//! Notify client of a game start.
- void game_start(boost::function<void ()> callback, std::vector<std::string> players);
+ virtual void game_start(boost::function<void ()> callback, std::vector<std::string> players);
//! Notify client of a round start.
- void round_start();
-
- typedef Message::RoundState::Player PlayerState;
+ virtual void round_start();
//! Send round state.
- void round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a);
+ virtual void round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const Tiles& d, const Actions& a);
//! Send round end.
- void round_end(boost::function<void ()> callback);
+ virtual void round_end(boost::function<void ()> callback);
//! Get action. Upon connection error, last element of expected_actions will be provided.
- void get_action(boost::function<void (Action)> callback, Actions expected_actions);
+ virtual void get_action(boost::function<void (Action)> callback, Actions expected_actions);
};
typedef std::vector<Client> Clients;