From 239c22a35258051e62c27173dfb513f689b03e77 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 23 Sep 2007 15:01:47 +0000 Subject: Simplified interface of the handler used for connections from game servers to account server. --- src/account-server/serverhandler.hpp | 111 ++++++++++------------------------- 1 file changed, 32 insertions(+), 79 deletions(-) (limited to 'src/account-server/serverhandler.hpp') 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 #include -#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 -- cgit v1.2.3-60-g2f50