Skip to content

Commit

Permalink
add empty json with null payload
Browse files Browse the repository at this point in the history
  • Loading branch information
danewalton-msft committed Oct 1, 2021
1 parent d1a663b commit 9e03329
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions iothub_client/src/iothub_client_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#define DO_WORK_FREQ_DEFAULT 1
#define DO_WORK_MAXIMUM_ALLOWED_FREQUENCY 100
#define CLIENT_CORE_METHOD_EMPTY_PAYLOAD "{}"

struct IOTHUB_QUEUE_CONTEXT_TAG;

Expand Down Expand Up @@ -385,6 +386,13 @@ static int iothub_ll_device_method_callback(const char* method_name, const unsig
USER_CALLBACK_INFO queue_cb_info;
queue_cb_info.type = CALLBACK_TYPE_DEVICE_METHOD;

// A NULL payload was sent from the service. Use empty JSON to signal to the user no payload.
if(size == 0)
{
payload = (const unsigned char*) CLIENT_CORE_METHOD_EMPTY_PAYLOAD;
size = strlen(CLIENT_CORE_METHOD_EMPTY_PAYLOAD);
}

result = make_method_calback_queue_context(&queue_cb_info, method_name, payload, size, method_id, queue_context);
if (result != 0)
{
Expand Down

0 comments on commit 9e03329

Please sign in to comment.