axl_bool vortex_alive_enable_check ( VortexConnection conn,
long  check_period,
int  max_unreply_count,
VortexAliveFailure  failure_handler 
)

Allows to enable alive supervision on the provided connection.

The function enables a permanent test every check_period to ensure the connection is working. The check is implemented by a simply request/reply with an unreplied tracking to ensure we detect connection lost even when power failures or network cable unplug.

The function accepts a max_unreply_count which usually is 0 (no unreplied messages accepted) or the amount of unreplied messages we are accepting until calling to failure handler or shutdown the connection.

The failure_handler is optional. If not provided, the alive check will call to shutdown the connection (vortex_connection_shutdown), activating connection on close configured (vortex_connection_set_on_close_full) so close handling is unified on the same place.

However, if failure_handler is defined, the alive check will not shutdown the connection and will call the handler.

Parameters:
conn The connection where the check will be enabled.
check_period The check period. It is defined in microseconds (1 second == 1000000 microseconds). To check every 20ms a connection pass 20000. It must be > 0, or the function will return axl_false.
max_unreply_count The maximum amount of unreplied messages we accept. It must be > 0 or the function will return axl_false.
failure_handler Optional handler called when a failure is detected.
Returns:
axl_true if the check was properly enabled on the connection, otherwise axl_false is returned.