diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-05-23 05:35:13 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-05-23 05:35:13 +0000 |
commit | 351f050dd77c7dfae7ab901b9dab08336e59b4fc (patch) | |
tree | 709142480b61e116eca5ac17685e29b6fe658e5a /src/connectionhandler.h | |
parent | 71ef3ccdc4d628e93d445251121f36a35c6f6a4e (diff) | |
download | manaserv-351f050dd77c7dfae7ab901b9dab08336e59b4fc.tar.gz manaserv-351f050dd77c7dfae7ab901b9dab08336e59b4fc.tar.bz2 manaserv-351f050dd77c7dfae7ab901b9dab08336e59b4fc.tar.xz manaserv-351f050dd77c7dfae7ab901b9dab08336e59b4fc.zip |
Split server into three logical servers: an account server, a chat
server, and a game server.
Diffstat (limited to 'src/connectionhandler.h')
-rw-r--r-- | src/connectionhandler.h | 69 |
1 files changed, 14 insertions, 55 deletions
diff --git a/src/connectionhandler.h b/src/connectionhandler.h index 1b4e8036..3ce8bdbe 100644 --- a/src/connectionhandler.h +++ b/src/connectionhandler.h @@ -25,14 +25,11 @@ #define _TMWSERV_CONNECTIONHANDLER_H_ #include <list> -#include <map> #include <enet/enet.h> -#include "being.h" - #define IN_BUFFER_SIZE 8192 -class MessageHandler; +class MessageIn; class MessageOut; class NetComputer; @@ -75,7 +72,12 @@ class ConnectionHandler * Process outgoing messages and listen to the server socket for * incoming messages and new connections. */ - void process(); + virtual void process(); + + /** + * Process outgoing messages. + */ + void flush(); /** * Called when a computer sends a packet to the network session. @@ -83,9 +85,9 @@ class ConnectionHandler //void receivePacket(NetComputer *computer, Packet *packet); /** - * Registers a message handler to handle a certain message type. + * Force disconnection of target computer. */ - void registerHandler(unsigned int msgId, MessageHandler *handler); + void forceDisconnect(NetComputer *); /** * Send packet to every client, used for announcements. @@ -101,9 +103,6 @@ class ConnectionHandler ENetAddress address; /**< Includes the port to listen to. */ ENetHost *host; /**< The host that listen for connections. */ - typedef std::map< unsigned int, MessageHandler * > HandlerMap; - HandlerMap handlers; - protected: /** * Called when a computer connects to the server. Initialize @@ -124,6 +123,11 @@ class ConnectionHandler */ virtual void computerDisconnected(NetComputer *) = 0; + /** + * Called when a message is received. + */ + virtual void processMessage(NetComputer *, MessageIn &) = 0; + typedef std::list<NetComputer*> NetComputers; /** * A list of pointers to the client structures created by @@ -132,49 +136,4 @@ class ConnectionHandler NetComputers clients; }; -/** - * Temporary placeholder until the connection handlers have been split. - */ -class ClientConnectionHandler: public ConnectionHandler -{ - public: - /** - * Send packet to client with matching BeingPtr - */ - void sendTo(tmwserv::BeingPtr, MessageOut &); - - /** - * Send packet to client with matching Being name - */ - void sendTo(std::string name, MessageOut &); - - /** - * Send packet to every client around the client on screen. - */ - void sendAround(tmwserv::BeingPtr, MessageOut &); - - /** - * Send packet to every client in a registered channel. - */ - void sendInChannel(short channelId, MessageOut &); - - /** - * tells a list of user they're leaving a channel. - */ - void makeUsersLeaveChannel(const short channelId); - - /** - * tells a list of user about an event in a chatchannel about a player. - */ - void warnUsersAboutPlayerEventInChat(const short channelId, - const std::string& userName, - const char eventId); - - protected: - virtual NetComputer *computerConnected(ENetPeer *); - virtual void computerDisconnected(NetComputer *); -}; - -extern ClientConnectionHandler *connectionHandler; - #endif |