You're reading the documentation for an older, but still supported version (1.33.4).
For information on the latest version, please have a look at 1.33.5.

set_on_disconnected

This function registers a callback function that automatically checks whether the connection to the robot controller has been terminated for an external reason or by the user. Use it to run your own code automatically when this event occurs.

Definition
DRFLEx.h within class CDRFLEx, public section

void set_on_disconnected(TOnDisconnectedCB pCallbackFunc) {
    _set_on_disconnected(_rbtCtrl, pCallbackFunc);
};

Parameter

Parameter Name

Data Type

Default Value

Description

pCallbackFunc

TOnDisconnectedCB

Refer to definition of callback function

Return
None

Note

When a connection ends (close_connection, loss of connection, or open_connection on an object that is already connected), every callback registered with a set_on_* function is unregistered, except those registered with set_on_disconnected, set_on_monitoring_ctrl_io_ex (with DRCF_VERSION 3, the default), set_on_rt_monitoring_data and set_on_rt_log_alarm, which stay registered. After each successful open_connection, register the other callbacks again and call setup_monitoring_version again. open_connection on a connected object closes the existing connection first and prints “Already connected : <ip>”.

See Rules for callback functions.

Example

void OnDisconnectedCB()
{
    // Needs the reconnection of the robot controller and error handling
}

drfl.set_on_disconnected(OnDisconnectedCB);

When registered, this callback function executes automatically when the connection between the robot controller and the client is lost. It allows the user to implement reconnection logic or error recovery procedures for stable operation in external environments.