From 18e73025a15b98aae008ffe5a19570a0e5ea19ef Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Tue, 7 Dec 2010 02:02:42 +0100 Subject: Completed framework for reconnection. Still missing client-fallback and resync upon reconnect. --- server/client.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'server/client.h') diff --git a/server/client.h b/server/client.h index 676264e..82968b4 100644 --- a/server/client.h +++ b/server/client.h @@ -2,6 +2,7 @@ #define CLIENT_H #include +#include #include #include #include @@ -16,9 +17,6 @@ class ClientBase { virtual ~ClientBase() {} - //! Return client's id. - virtual unsigned int id() = 0; - //! Return client's nick. virtual std::string nick() = 0; @@ -44,21 +42,29 @@ class Client : public ClientBase, public boost::enable_shared_from_this public: typedef boost::shared_ptr p; - static p create(Connection::p c, boost::function f); + //! 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; - unsigned int id_; - std::string nick_; - Client(Connection::p c); + Client(Connection::p c, std::string n); //! Start communicating. - void start(boost::function f); + void start(); //! Handle Login-message. void handle_login(Message::p msg, boost::function login_callback); @@ -76,9 +82,6 @@ class Client : public ClientBase, public boost::enable_shared_from_this //! Inform client of lobby status (available game modes). void lobby_status(const std::vector& game_modes, boost::function callback); - //! Return client's id. - virtual unsigned int id(); - //! Return client's nick. virtual std::string nick(); @@ -97,10 +100,7 @@ class Client : public ClientBase, public boost::enable_shared_from_this //! Get action. Upon connection error, last element of expected_actions will be provided. virtual void get_action(boost::function callback, Actions expected_actions); - //! Dis-connect a player. - virtual void disconnect(); - - //! Re-connect a player. + //! Reconnect a player. virtual void reconnect(Connection::p c); }; -- cgit v1.2.3