setHeartbeatTimes

setHeartbeatTimes — sets the period of the heartbeat timers.

Syntax

For C++:

ST_STATUS setHeartbeatTimes(long  heartbeat_ms,
 long  timeout_ms);

For Java and C#:

Exception setHeartbeatTimes(long  heartbeat_ms,
 long  timeout_ms);

Parameters

heartbeat_ms

The period in milliseconds for the heartbeat timer, or 0 if a timer will not be used.

timeout_ms

The period in milliseconds for the timeout timer, or 0 if a timer will not be used.

Returns

For C++:

ST_OK if the timer values accepted, otherwise ST_ERROR. ST_ERROR can occur for the following reasons:

    The timeout timer value is not greater than heartbeat (if both values are greater than 0).

    The timers were already active and either timer failed to restart.

Description

The DataHub and API provide two heartbeat services to ensure the integrity of the connection:

    A local, internal timeout timer, which when it fires, will close the connection and generate an error.

    A periodic 'alive' heartbeat message from the DataHub, which triggers the virtual method onAlive.

The timers can be started with startHeartbeatTimers once the respective periods have been set. If a timer is already running when setHeartbeatTimes is called, then that timer is restarted with the new period. If the timer is already running and the specified period is 0, then the timer is stopped.

The timeout timer is automatically reset whenever there is any activity over the connection, including the heartbeat timer message.

See Also

getHeartbeat, getTimeout, startHeartbeatTimers, cancelHeartbeatTimers