From 4282a9d069b3bedc8888a4e6202f2b066233d4ec Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 25 Nov 2010 03:01:43 +0100 Subject: 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. --- server/client.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 server/client.h (limited to 'server/client.h') 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 +#include +#include +#include +#include + +#include "connection.h" + +class Client : public boost::enable_shared_from_this { + public: + typedef boost::shared_ptr p; + + static p create(Connection::p c, boost::function f); + + private: + Connection::p connection; + + boost::asio::deadline_timer timer; + + std::string nick_; + + Client(Connection::p c); + + //! Start communicating. + void start(boost::function f); + + //! Handle Login-message. + void handle_login(Message::p msg, boost::function lobby_callback); + + //! Handle Ready-message. + void handle_ready(Message::p msg, boost::function ready_callback); + + //! Handle Action-message. + void handle_action(Message::p msg, boost::function 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 callback, std::vector 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 callback, Actions expected_actions); + + void kill_action(); +}; + +typedef std::vector Clients; + +#endif -- cgit v1.2.3