SPAOP
|
A class for connection timeout control. More...
#include <PingControl.h>
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... | |
A class for connection timeout control.
wonder::PingControl::PingControl | ( | ConnectionTimer::Factory * | timerFactory, |
PingControl::Listener * | listener, | ||
const int | connectionID, | ||
const int | maxLost = MAX_PINGS_LOST |
||
) |
Constructor.
timerFactory | A ConnectionTimer::Factory that the constructor will use to create the PingControl's internal ConncectionTimer. |
listener | The Listener that will be notified when a lost connection is detected. |
connectionID | An ID that will be passed to the listener in case the listener's connectionLost method is called. |
maxLost | How many pings may be lost before the connection is considered to be lost (and the listener's connectionLost method is called). |
|
virtual |
Destructor.
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.
void wonder::PingControl::stop | ( | ) |
Stops the ping control.
Be aware that further calls of onPing() will restart PingControl.