#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: //! 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(); typedef Message::RoundState::Player PlayerState; //! 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); //! Send round end. void round_end(); //! Get action. Upon connection error, last element of expected_actions will be provided. void get_action(boost::function callback, Actions expected_actions); }; typedef std::vector Clients; #endif