SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | List of all members
wonder::PingControl Class Reference

A class for connection timeout control. More...

#include <PingControl.h>

Inheritance diagram for wonder::PingControl:
Inheritance graph
[legend]
Collaboration diagram for wonder::PingControl:
Collaboration graph
[legend]

Classes

class  Listener
 A listener class for callbacks in case loss of connection is detected. More...
 

Public Member Functions

 PingControl (ConnectionTimer::Factory *timerFactory, Listener *listener, const int connectionID, const int maxLost=MAX_PINGS_LOST)
 Constructor. More...
 
virtual ~PingControl ()
 Destructor. More...
 
void start ()
 Starts the ping control, resetting the lost pings count. More...
 
void stop ()
 Stops the ping control. More...
 
void onPing ()
 Called when an incoming ping is received. More...
 
- Public Member Functions inherited from wonder::ConnectionTimer::Listener
virtual ~Listener ()
 Destructor. More...
 

Detailed Description

A class for connection timeout control.

Constructor & Destructor Documentation

wonder::PingControl::PingControl ( ConnectionTimer::Factory timerFactory,
PingControl::Listener listener,
const int  connectionID,
const int  maxLost = MAX_PINGS_LOST 
)

Constructor.

Parameters
timerFactoryA ConnectionTimer::Factory that the constructor will use to create the PingControl's internal ConncectionTimer.
listenerThe Listener that will be notified when a lost connection is detected.
connectionIDAn ID that will be passed to the listener in case the listener's connectionLost method is called.
maxLostHow many pings may be lost before the connection is considered to be lost (and the listener's connectionLost method is called).
wonder::PingControl::~PingControl ( )
virtual

Destructor.

Member Function Documentation

void wonder::PingControl::onPing ( )

Called when an incoming ping is received.

(Depending on how this class is used, the incoming ping could also be a "pong".) If this PingControl is not started yet, a call to this method will also start PingControl.

void wonder::PingControl::start ( )

Starts the ping control, resetting the lost pings count.

The onPing() method will start ping control as well (without resetting the lost pings count). If it is uncertain if the counterpart will send pings at all, consider not calling start() and rely on onPing() to start PingControl.

See Also
onPing().
void wonder::PingControl::stop ( )

Stops the ping control.

Be aware that further calls of onPing() will restart PingControl.

See Also
onPing().