summaryrefslogtreecommitdiff
path: root/src/account-server/serverhandler.hpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-09-23 15:01:47 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-09-23 15:01:47 +0000
commit239c22a35258051e62c27173dfb513f689b03e77 (patch)
tree19cba4d5eec590056cea9358ea0ae51a82840898 /src/account-server/serverhandler.hpp
parent0d00b4e7f49a0373d350353e62e08cdd903628e9 (diff)
downloadmanaserv-239c22a35258051e62c27173dfb513f689b03e77.tar.gz
manaserv-239c22a35258051e62c27173dfb513f689b03e77.tar.bz2
manaserv-239c22a35258051e62c27173dfb513f689b03e77.tar.xz
manaserv-239c22a35258051e62c27173dfb513f689b03e77.zip
Simplified interface of the handler used for connections from game servers to account server.
Diffstat (limited to 'src/account-server/serverhandler.hpp')
-rw-r--r--src/account-server/serverhandler.hpp111
1 files changed, 32 insertions, 79 deletions
diff --git a/src/account-server/serverhandler.hpp b/src/account-server/serverhandler.hpp
index 76151569..e5309cff 100644
--- a/src/account-server/serverhandler.hpp
+++ b/src/account-server/serverhandler.hpp
@@ -27,87 +27,40 @@
#include <iosfwd>
#include <string>
-#include "net/connectionhandler.hpp"
-
-class AccountClient;
class Character;
-struct GameServer;
-/**
- * Manages communications with all the game servers. This class also keeps
- * track of the maps each game server supports.
- */
-class ServerHandler: public ConnectionHandler
+namespace GameServerHandler
{
- public:
- /**
- * Starts the handler on the given port.
- */
- bool startListen(enet_uint16 port);
-
- /**
- * Returns the information a client needs to connect to the game server
- * corresponding to the given map ID.
- */
- bool getGameServerFromMap(int, std::string &address, int &port) const;
-
- /**
- * Sends a magic token and character data to the relevant game server.
- */
- void registerGameClient(std::string const &, Character *);
-
-// There is no rationale for having a character name, but not its ID.
-#if 0
- /**
- * Get character (temp used by chat server).
- */
- CharacterPtr getCharacter(const std::string &name);
-#endif
-
- /**
- * Make client join the specified guild channel
- */
- void enterChannel(const std::string &guildName, Character *player);
-
- /**
- * Dumps per-server statistics into given stream
- */
- void dumpStatistics(std::ostream &) const;
-
- protected:
- /**
- * Processes server messages.
- */
- void processMessage(NetComputer *computer, MessageIn &message);
-
- /**
- * Called when a game server connects. Initializes a simple NetComputer
- * as these connections are stateless.
- */
- NetComputer *computerConnected(ENetPeer *peer);
-
- /**
- * Called when a game server disconnects.
- */
- void computerDisconnected(NetComputer *comp);
-
- private:
-
- /**
- * Returns the information a client needs to connect to the game server
- * corresponding to the given map ID.
- */
- GameServer *getGameServerFromMap(int) const;
-
-#if 0
- /**
- * Send invite to user
- */
- void sendInvite(const std::string &invitedName, const std::string &inviterName,
- const std::string &guildName);
-#endif
-};
-
-extern ServerHandler *serverHandler;
+ /**
+ * Creates a connection handler and starts listening on given port.
+ */
+ bool initialize(int port);
+
+ /**
+ * Stops listening to messages and destroys the connection handler.
+ */
+ void deinitialize();
+
+ /**
+ * Returns the information a client needs to connect to the game server
+ * corresponding to the given map ID.
+ */
+ bool getGameServerFromMap(int, std::string &address, int &port);
+
+ /**
+ * Warns a game server about a soon-to-connect client.
+ */
+ void registerClient(std::string const &token, Character *);
+
+ /**
+ * Dumps per-server statistics into given stream
+ */
+ void dumpStatistics(std::ostream &);
+
+ /**
+ * Processes messages received by the connection handler.
+ */
+ void process();
+}
#endif