nabto_client_future_set_callback2()

DESCRIPTION

Set a callback to be called when the future resolves.

This replaces nabto_client_future_set_callback(). This new function returns an error code which fixes the case where the client context has been stopped meaning the future queue is closed and resolving the future is impossible. In this case, this function will return the stopped error instead of resolving the future.

It is not allowed to call the following functions from the callback as they could either crash the application or lead to the callback thread being blocked.

  • nabto_client_future_wait
  • nabto_client_future_timed_wait
  • nabto_client_stop
  • nabto_client_free

DECLARATION

NABTO_CLIENT_DECL_PREFIX NabtoClientError NABTO_CLIENT_API
nabto_client_future_set_callback2(NabtoClientFuture* future,
    NabtoClientFutureCallback callback,
    void* data)

PARAMETERS

future:
[in] The future.
callback:
[in] The callback.
data:
[in] User data for the callback.

RETURNS

NABTO_CLIENT_EC_OK if the callback is set