diff options
Diffstat (limited to 'server/client.h')
-rw-r--r-- | server/client.h | 66 |
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 |