From fae209a9e93400c3a2072befda9c820634cf9278 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 25 Dec 2010 12:54:59 +0100 Subject: Restructured repository. --- server/client.h | 132 -------------------------------------------------------- 1 file changed, 132 deletions(-) delete mode 100644 server/client.h (limited to 'server/client.h') diff --git a/server/client.h b/server/client.h deleted file mode 100644 index e6cfcc7..0000000 --- a/server/client.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef CLIENT_H -#define CLIENT_H - -#include -#include -#include -#include -#include -#include - -#include "connection.h" - -//! Abstract client base class. -class ClientBase { - public: - typedef boost::shared_ptr p; - - virtual ~ClientBase() {} - - //! Return client's nick. - virtual std::string nick() = 0; - - //! Notify client of a game start. - virtual void game_start(boost::function callback, std::vector players) = 0; - - //! Notify client of a round start. - virtual void round_start() = 0; - - //! Send round state. - virtual void round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const GameState& g, const Actions& a) = 0; - - //! Send round end. - virtual void round_end(Message::RoundEnd::p msg, boost::function callback) = 0; - - //! Get action. Upon connection error, last element of expected_actions will be provided. - virtual void get_action(boost::function callback, Actions expected_actions) = 0; - - virtual void game_end(Message::GameEnd::p msg, boost::function callback) = 0; - -}; - -//! Class implementing ClientBase for real clients. -class Client : public ClientBase, public boost::enable_shared_from_this { - public: - typedef boost::shared_ptr p; - - //! Construct and return a new Client instance. - static p create(Connection::p c, std::string n); - - //! Check if a Client instance of the user already exists and return it. - static p exists(Message::Login::p login_msg); - - ~Client(); - - private: - uint64_t cookie; - - static std::map > client_list; - - Connection::p connection; - - boost::asio::deadline_timer timer; - - std::string nick_; - - Client(Connection::p c, std::string n); - - //! Start communicating. - void start(); - - //! Handle Login-message. - void handle_login(Message::p msg, boost::function login_callback); - - //! Handle LobbyAction-message. - void handle_lobby(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: - //! Inform client of lobby status (available game modes). - void lobby_status(const std::vector& game_modes, boost::function callback); - - //! Return client's nick. - virtual std::string nick(); - - //! Notify client of a game start. - virtual void game_start(boost::function callback, std::vector players); - - //! Notify client of a round start. - virtual void round_start(); - - //! Send round state. - virtual void round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const GameState& g, const Actions& a); - - //! Send round end. - virtual void round_end(Message::RoundEnd::p msg, boost::function callback); - - //! Get action. Upon connection error, last element of expected_actions will be provided. - virtual void get_action(boost::function callback, Actions expected_actions); - - //! Reconnect a player. - virtual void reconnect(Connection::p c); - - virtual void game_end(Message::GameEnd::p msg, boost::function callback); -}; - -typedef std::vector Clients; - -class ClientDumb : public ClientBase { - public: - virtual unsigned int id(); - - virtual std::string nick(); - - virtual void game_start(boost::function callback, std::vector players); - - virtual void round_start(); - - virtual void round_state(const PlayerState& pl_d, const PlayerState& pl_r, const PlayerState& pl_u, const PlayerState& pl_l, const GameState& g, const Actions& a); - - virtual void round_end(Message::RoundEnd::p msg, boost::function callback); - - virtual void get_action(boost::function callback, Actions expected_actions); - - virtual void game_end(Message::GameEnd::p msg, boost::function callback); -}; - -#endif -- cgit v1.2.3