BAOS SDK  18.2.0
Public Member Functions | List of all members
kdrive::baos::BaosHeartbeat Class Reference

BaosHeartbeat sends periodically a heartbeat. More...

#include <BaosHeartbeat.h>

Inheritance diagram for kdrive::baos::BaosHeartbeat:
kdrive::baos::ScopedBaosHeartbeat

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...
 

Detailed Description

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.

Deprecated:
In a previous version did the StreamConnector no heartbeat. Now th StreamConnector implemented internally the heartbeat. So this class is no more needed. Its exists only for backward compatibility.

Constructor & Destructor Documentation

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.

BaosHeartbeat::~BaosHeartbeat ( )
virtual

Destroys the BaosHeartbeat Stops the heartbeat thread if it is still active.

Member Function Documentation

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.


The documentation for this class was generated from the following files: