ConnectionHandler Class Reference

This class represents the connection handler interface. More...

#include <connectionhandler.hpp>

Inheritance diagram for ConnectionHandler:

ChatHandler GameHandler ServerHandler

List of all members.

Public Member Functions

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)
 Called when a computer sends a packet to the network session.
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 reconnects to 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.


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 37 of file connectionhandler.hpp.


Member Function Documentation

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

Definition at line 76 of file connectionhandler.cpp.

References clients, computerConnected(), computerDisconnected(), and processMessage().

void ConnectionHandler::sendToEveryone ( const MessageOut msg  ) 

Called when a computer sends a packet to the network session.

Send packet to every client, used for announcements.

Definition at line 138 of file connectionhandler.cpp.

References clients.

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 ServerHandler, ChatHandler, and GameHandler.

Referenced by process().

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

Called when a computer reconnects to the server.

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 ServerHandler, ChatHandler, and GameHandler.

Referenced by process().


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:46 2009 for TMW Server Collection by  doxygen 1.5.5