ionflux.org | Impressum

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

TCPMessageClient. More...

#include <TCPMessageClient.hpp>

Inheritance diagram for Ionflux::Tools::TCPMessageClient:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TCPMessageClient ()
 Constructor.
 TCPMessageClient (bool initInteractive)
 Constructor.
virtual ~TCPMessageClient ()
 Destructor.
virtual void onInput (const std::string &line)
 Event handler for standard input.
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 &peer)
 Event handler for new connections.
virtual void onReceive (TCPRemotePeer &peer)
 Event handler for received data.

Detailed Description

TCPMessageClient.

A Message based TCP client. This works like a TCPClient, 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::TCPMessageClient::TCPMessageClient  ) 
 

Constructor.

Construct new TCPMessageClient object.

Ionflux::Tools::TCPMessageClient::TCPMessageClient bool  initInteractive  ) 
 

Constructor.

Construct new TCPMessageClient object.

Parameters:
initInteractive Whether this client should run interactively (i.e. read data from standard input).

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

Destructor.

Destruct TCPMessageClient object.


Member Function Documentation

void Ionflux::Tools::TCPMessageClient::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::TCPClient.

Reimplemented in Ionflux::Tools::TCPAuthClient.

void Ionflux::Tools::TCPMessageClient::onConnect TCPRemotePeer peer  )  [protected, virtual]
 

Event handler for new connections.

This is called by the main loop whenever a connection to a peer is successfully established.

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

Reimplemented from Ionflux::Tools::TCPClient.

Reimplemented in Ionflux::Tools::TCPAuthClient.

void Ionflux::Tools::TCPMessageClient::onInput const std::string &  line  )  [virtual]
 

Event handler for standard input.

For interactive clients, this is called by the main loop whenever data is available on standard input.

Parameters:
line Data from standard input.

Reimplemented from Ionflux::Tools::TCPClient.

void Ionflux::Tools::TCPMessageClient::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::TCPAuthClient.

void Ionflux::Tools::TCPMessageClient::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::TCPAuthClient.

void Ionflux::Tools::TCPMessageClient::onReceive TCPRemotePeer peer  )  [protected, virtual]
 

Event handler for received data.

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

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:
peer The peer which caused the event.

Reimplemented from Ionflux::Tools::TCPClient.


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