IoTHubDeviceClient_SetMessageCallback()

Sets up the message callback to be invoked when IoT Hub issues a message to the device. This is a blocking call.

Syntax

#include "azure-iot-sdk-c/iothub_client/inc/iothub_device_client.h"

IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SetMessageCallback(
  IOTHUB_DEVICE_CLIENT_HANDLE           iotHubClientHandle,
  IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC  messageCallback,
  void *                                userContextCallback
);

Parameters

  • iotHubClientHandle The handle created by a call to the create function.

  • messageCallback The callback specified by the device for receiving messages from IoT Hub.

  • userContextCallback User specified context that will be provided to the callback. This can be NULL.

NOTE: The application behavior is undefined if the user calls the IoTHubDeviceClient_Destroy function from within any callback.

Return Value

IOTHUB_CLIENT_OK upon success or an error code upon failure.