summaryrefslogtreecommitdiff
path: root/server/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'server/client.h')
-rw-r--r--server/client.h30
1 files changed, 15 insertions, 15 deletions
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 <string>
+#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/function.hpp>
@@ -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<Client>
public:
typedef boost::shared_ptr<Client> p;
- static p create(Connection::p c, boost::function<void (Client::p)> 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<uint64_t, boost::weak_ptr<Client> > 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<void (Client::p)> f);
+ void start();
//! Handle Login-message.
void handle_login(Message::p msg, boost::function<void (Client::p)> login_callback);
@@ -76,9 +82,6 @@ class Client : public ClientBase, public boost::enable_shared_from_this<Client>
//! Inform client of lobby status (available game modes).
void lobby_status(const std::vector<std::string>& game_modes, boost::function<void (int)> 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<Client>
//! Get action. Upon connection error, last element of expected_actions will be provided.
virtual void get_action(boost::function<void (Action)> callback, Actions expected_actions);
- //! Dis-connect a player.
- virtual void disconnect();
-
- //! Re-connect a player.
+ //! Reconnect a player.
virtual void reconnect(Connection::p c);
};