summaryrefslogtreecommitdiff
path: root/server/client.h
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 03:01:43 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 03:01:43 +0100
commit4282a9d069b3bedc8888a4e6202f2b066233d4ec (patch)
tree8e0646804a7b33883be5867833e7b02004ddca1c /server/client.h
parentd5aae396856ee801eb2e2420b786fda2f13cf391 (diff)
Rename Player to Client, to better reflect what it represents.
A Player should be specific to a game, while a Client may participate in several.
Diffstat (limited to 'server/client.h')
-rw-r--r--server/client.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/server/client.h b/server/client.h
new file mode 100644
index 0000000..ad5df64
--- /dev/null
+++ b/server/client.h
@@ -0,0 +1,66 @@
+#ifndef CLIENT_H
+#define CLIENT_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 Client : public boost::enable_shared_from_this<Client> {
+ public:
+ typedef boost::shared_ptr<Client> p;
+
+ static p create(Connection::p c, boost::function<void (Client::p)> f);
+
+ private:
+ Connection::p connection;
+
+ boost::asio::deadline_timer timer;
+
+ std::string nick_;
+
+ Client(Connection::p c);
+
+ //! Start communicating.
+ void start(boost::function<void (Client::p)> f);
+
+ //! Handle Login-message.
+ void handle_login(Message::p msg, boost::function<void (Client::p)> lobby_callback);
+
+ //! Handle Ready-message.
+ void handle_ready(Message::p msg, boost::function<void ()> ready_callback);
+
+ //! Handle Action-message.
+ void handle_action(Message::p msg, boost::function<void (Action)> action_callback, Actions expected_actions);
+
+ public:
+ //! The ID of the client
+ int id;
+
+ //! Return client's nick.
+ std::string nick();
+
+ //! Notify client of a game start.
+ void game_start(boost::function<void ()> callback, std::vector<Client::p> players);
+
+ //! Notify client of a round start.
+ void round_start();
+
+ //! Send round state.
+ void round_state(State state);
+
+ //! Send round end.
+ void round_end();
+
+ //! Get action.
+ void get_action(boost::function<void (Action)> callback, Actions expected_actions);
+
+ void kill_action();
+};
+
+typedef std::vector<Client> Clients;
+
+#endif