Function rmw_service_set_on_new_request_callback

Function Documentation

rmw_ret_t rmw_service_set_on_new_request_callback(rmw_service_t *service, rmw_event_callback_t callback, const void *user_data)

Set the on new request callback function for the service.

This API sets the callback function to be called whenever the service is notified about a new request.

This callback is called for each new request received by the service. If requests arrive before the callback is registered, the number_of_events argument given to the callback may be > 1.

The callback may be called from a thread that the rmw implementation created, rather than a thread owned by the user, i.e. some thread other than user owned threads calling rmw functions such as rmw_wait() or rmw_send_request().

This function is thread-safe. This is required of the rmw implementation because the callback may be called from any middleware thread, and this function could be called by the user at any time.

Parameters:
  • service[in] The service on which to set the callback

  • callback[in] The callback to be called when new requests arrive, can be NULL to clear the registered callback

  • user_data[in] Given to the callback when called later, may be NULL

Returns:

RMW_RET_OK if callback was set to the listener, or

Returns:

RMW_RET_INVALID_ARGUMENT if service is NULL, or

Returns:

RMW_RET_UNSUPPORTED if the API is not implemented in the dds implementation