ConnectionHandler Class Reference

#include <connectionhandler.hpp>

Inheritance diagram for ConnectionHandler:

AccountHandler ChatHandler GameHandler ServerHandler List of all members.

Detailed Description

This class represents the connection handler interface.

The connection handler will respond to connect/reconnect/disconnect events and handle incoming messages, passing them on to registered message handlers.

Definition at line 39 of file connectionhandler.hpp.

Public Member Functions

virtual ~ConnectionHandler ()
bool startListen (enet_uint16 port)
 Open the server socket.
void stopListen ()
 Disconnect all the clients and close the server socket.
virtual void process (enet_uint32 timeout=0)
 Process outgoing messages and listen to the server socket for incoming messages and new connections.
void flush ()
 Process outgoing messages.
void sendToEveryone (const MessageOut &msg)
 Send packet to every client, used for announcements.
unsigned int getClientNumber ()
 Return the number of connected clients.

Protected Types

typedef std::list< NetComputer * > NetComputers

Protected Member Functions

virtual NetComputercomputerConnected (ENetPeer *peer)=0
 Called when a computer connects to the server.
virtual void computerDisconnected (NetComputer *)=0
 Called when a computer disconnects from the server.
virtual void processMessage (NetComputer *, MessageIn &)=0
 Called when a message is received.

Protected Attributes

NetComputers clients
 A list of pointers to the client structures created by computerConnected.

Private Attributes

ENetAddress address
 Includes the port to listen to.
ENetHost * host
 The host that listen for connections.


Member Typedef Documentation

typedef std::list<NetComputer*> ConnectionHandler::NetComputers [protected]
 

Definition at line 112 of file connectionhandler.hpp.


Constructor & Destructor Documentation

virtual ConnectionHandler::~ConnectionHandler  )  [inline, virtual]
 

Definition at line 42 of file connectionhandler.hpp.


Member Function Documentation

virtual NetComputer* ConnectionHandler::computerConnected ENetPeer *  peer  )  [protected, pure virtual]
 

Called when a computer connects to the server.

Initialize an object derived of NetComputer.

Implemented in AccountHandler, ServerHandler, ChatHandler, and GameHandler.

virtual void ConnectionHandler::computerDisconnected NetComputer  )  [protected, pure virtual]
 

Called when a computer disconnects from the server.

Note: After returning from this method the NetComputer reference is no longer guaranteed to be valid.

Implemented in AccountHandler, ServerHandler, ChatHandler, and GameHandler.

void ConnectionHandler::flush  ) 
 

Process outgoing messages.

Definition at line 71 of file connectionhandler.cpp.

unsigned int ConnectionHandler::getClientNumber  ) 
 

Return the number of connected clients.

Definition at line 151 of file connectionhandler.cpp.

void ConnectionHandler::process enet_uint32  timeout = 0  )  [virtual]
 

Process outgoing messages and listen to the server socket for incoming messages and new connections.

an optional timeout in milliseconds to wait for something to happen when there is nothing to do

Reimplemented in ChatHandler.

Definition at line 76 of file connectionhandler.cpp.

virtual void ConnectionHandler::processMessage NetComputer ,
MessageIn
[protected, pure virtual]
 

Called when a message is received.

Implemented in AccountHandler, ServerHandler, ChatHandler, and GameHandler.

void ConnectionHandler::sendToEveryone const MessageOut msg  ) 
 

Send packet to every client, used for announcements.

Definition at line 142 of file connectionhandler.cpp.

bool ConnectionHandler::startListen enet_uint16  port  ) 
 

Open the server socket.

Reimplemented in AccountHandler, ServerHandler, ChatHandler, and GameHandler.

Definition at line 34 of file connectionhandler.cpp.

void ConnectionHandler::stopListen  ) 
 

Disconnect all the clients and close the server socket.

Definition at line 49 of file connectionhandler.cpp.


Member Data Documentation

ENetAddress ConnectionHandler::address [private]
 

Includes the port to listen to.

Definition at line 84 of file connectionhandler.hpp.

NetComputers ConnectionHandler::clients [protected]
 

A list of pointers to the client structures created by computerConnected.

Definition at line 117 of file connectionhandler.hpp.

ENetHost* ConnectionHandler::host [private]
 

The host that listen for connections.

Definition at line 85 of file connectionhandler.hpp.


The documentation for this class was generated from the following files:
Generated on Fri Mar 30 15:39:18 2007 for TMW Server by  doxygen 1.3.9.1