Invoke a callback
A callback function (or just callback) is a function that you write to handle a particular event.
The DataBlade®
API provides
the following functions to handle invocation of a callback function.
Callback task | DataBlade® API function |
---|---|
Register a callback | mi_register_callback(), mi_unregister_callback() |
Enable a callback | mi_enable_callback() |
Disable a callback | mi_disable_callback() |
Retrieve a pointer to the callback function | mi_retrieve_callback() |
For the DataBlade®
API to
invoke a callback when the associated event occurs, the following
conditions must be met in the DataBlade®
API module:
- The module must register the callback for the event on the current
connection.
The mi_register_callback() function registers a callback for a particular event. The DataBlade® API module that requires the event handling must register the callback.
- The registered callback must be enabled.
It is possible to disable a registered callback to suspend its invocation. The mi_enable_callback() function enables a previously disabled callback.
In addition, a module can save a registered callback and restore it at a later time.