ionflux.org | Impressum

Ionflux::Tools::TCPMessageServer Class Reference
[Network interface]

Message based TCP server. More...

#include <TCPMessageServer.hpp>

Inheritance diagram for Ionflux::Tools::TCPMessageServer:

Inheritance graph
[legend]
Collaboration diagram for Ionflux::Tools::TCPMessageServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TCPMessageServer ()
 Constructor.
virtual ~TCPMessageServer ()
 Destructor.
virtual void onMessage (TCPRemotePeer &peer)
 Event handler for received messages.
virtual void onInvalidMessage (TCPRemotePeer &peer)
 Event handler for invalid messages.
virtual void broadcast (const std::string &bytes)
 Broadcast bytes.

Protected Member Functions

virtual void onConnect (TCPRemotePeer &client)
 Event handler for new connections.
virtual void onReceive (TCPRemotePeer &client)
 Event handler for received data.

Detailed Description

Message based TCP server.

A Message based TCP server. This works like a TCPServer, except that incoming data is unpacked into a message (if possible). Outgoing data is wrapped into a message and serialized before being sent over the socket.


Constructor & Destructor Documentation

Ionflux::Tools::TCPMessageServer::TCPMessageServer  ) 
 

Constructor.

Construct new TCPMessageServer object.

Ionflux::Tools::TCPMessageServer::~TCPMessageServer  )  [virtual]
 

Destructor.

Destruct TCPMessageServer object.


Member Function Documentation

void Ionflux::Tools::TCPMessageServer::broadcast const std::string &  bytes  )  [virtual]
 

Broadcast bytes.

Sends the specified byte string to all connected peers.

Parameters:
bytes The bytes to broadcast.

Reimplemented from Ionflux::Tools::TCPServer.

Reimplemented in Ionflux::Tools::TCPAuthServer.

void Ionflux::Tools::TCPMessageServer::onConnect TCPRemotePeer client  )  [protected, virtual]
 

Event handler for new connections.

This is called by the main loop whenever a new client connects.

Note:
Override this to implement your own connection handling.
Parameters:
client The client which caused the event.

Reimplemented from Ionflux::Tools::TCPServer.

Reimplemented in Ionflux::Tools::TCPAuthServer.

void Ionflux::Tools::TCPMessageServer::onInvalidMessage TCPRemotePeer peer  )  [virtual]
 

Event handler for invalid messages.

This is called whenever an invalid message is received from a peer.

Note:
Override this to implement your own invalid message handling.
Parameters:
peer The peer which caused the event.

Implements Ionflux::Tools::MessageHandler.

Reimplemented in Ionflux::Tools::TCPAuthServer.

void Ionflux::Tools::TCPMessageServer::onMessage TCPRemotePeer peer  )  [virtual]
 

Event handler for received messages.

This is called whenever a valid message is received from a peer. The received message will be available from TCPRemotePeer::getMessage().

Note:
Override this to implement your own message handling.
Parameters:
peer The peer which caused the event.

Implements Ionflux::Tools::MessageHandler.

Reimplemented in Ionflux::Tools::TCPAuthServer.

void Ionflux::Tools::TCPMessageServer::onReceive TCPRemotePeer client  )  [protected, virtual]
 

Event handler for received data.

This is called by the main loop whenever data is received from a client. The received bytes will be appended to the receive buffer of the remote client.

Note:
Override this to implement your own received data handling. Remember that it is your responsibility to empty the receive buffer after you are done processing data.
Parameters:
client The client which caused the event.

Reimplemented from Ionflux::Tools::TCPServer.


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:10:55 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6