BAOS SDK
18.2.0
|
BaosHeartbeat sends periodically a heartbeat. More...
#include <BaosHeartbeat.h>
Public Member Functions | |
BaosHeartbeat (std::shared_ptr< BaosConnector > connector, unsigned int interval=1000) | |
Creates a BaosHeartbeat and associates it with a connection precondition: connector is not null. More... | |
virtual | ~BaosHeartbeat () |
Destroys the BaosHeartbeat Stops the heartbeat thread if it is still active. More... | |
void | start () |
Starts the heartbeat thread. More... | |
void | stop () |
Stops the heartbeat thread. More... | |
bool | isAlive () const |
Returns true if the last request was successful. More... | |
unsigned long | getTimeSinceReset () const |
Returns the last successful value of the server item time since reset. More... | |
void | setAutoTerminate (bool autoTerminate, int failCount=3) |
If autoTerminate is true we disconnect the connection and raise the terminated event as soon as isAlive is false. More... | |
BaosHeartbeat sends periodically a heartbeat.
We can also use this class to monitor the server connection. If there is a problem with the heartbeat we can auto-terminate the connection and raise an event. This is disabled by default to ensure backward compatibility with the original implementation.
BaosHeartbeat::BaosHeartbeat | ( | std::shared_ptr< BaosConnector > | connector, |
unsigned int | interval = 1000 |
||
) |
Creates a BaosHeartbeat and associates it with a connection precondition: connector is not null.
|
virtual |
Destroys the BaosHeartbeat Stops the heartbeat thread if it is still active.
unsigned long BaosHeartbeat::getTimeSinceReset | ( | ) | const |
Returns the last successful value of the server item time since reset.
This is called periodically as the heartbeat
bool BaosHeartbeat::isAlive | ( | ) | const |
Returns true if the last request was successful.
void BaosHeartbeat::setAutoTerminate | ( | bool | autoTerminate, |
int | failCount = 3 |
||
) |
If autoTerminate is true we disconnect the connection and raise the terminated event as soon as isAlive is false.
void BaosHeartbeat::start | ( | ) |
Starts the heartbeat thread.
If the thread has already been started nothing will happen.
void BaosHeartbeat::stop | ( | ) |
Stops the heartbeat thread.
If the thread is already stopped nothing will happen.