A small memory footprint AMQP implimentation
Dependents: iothub_client_sample_amqp remote_monitoring simplesample_amqp
cbs.c@6:641a9672db08, 2016-07-29 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Fri Jul 29 15:58:39 2016 -0700
- Revision:
- 6:641a9672db08
- Parent:
- 5:ae49385aff34
- Child:
- 17:923575db8b2d
1.0.10
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Azure.IoT Build | 0:6ae2f7bca550 | 1 | // Copyright (c) Microsoft. All rights reserved. |
Azure.IoT Build | 0:6ae2f7bca550 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
Azure.IoT Build | 0:6ae2f7bca550 | 3 | |
Azure.IoT Build | 0:6ae2f7bca550 | 4 | #include <stdlib.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 5 | #ifdef _CRTDBG_MAP_ALLOC |
Azure.IoT Build | 0:6ae2f7bca550 | 6 | #include <crtdbg.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 7 | #endif |
Azure.IoT Build | 0:6ae2f7bca550 | 8 | |
AzureIoTClient | 6:641a9672db08 | 9 | #include <stdbool.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 10 | #include <stdio.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 11 | #include <string.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 12 | #include "azure_uamqp_c/cbs.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 13 | #include "azure_uamqp_c/amqp_management.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 14 | #include "azure_uamqp_c/amqpalloc.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 15 | #include "azure_uamqp_c/session.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 16 | |
Azure.IoT Build | 0:6ae2f7bca550 | 17 | typedef struct CBS_INSTANCE_TAG |
Azure.IoT Build | 0:6ae2f7bca550 | 18 | { |
AzureIoTClient | 6:641a9672db08 | 19 | AMQP_MANAGEMENT_HANDLE amqp_management; |
Azure.IoT Build | 0:6ae2f7bca550 | 20 | } CBS_INSTANCE; |
Azure.IoT Build | 0:6ae2f7bca550 | 21 | |
Azure.IoT Build | 0:6ae2f7bca550 | 22 | static int add_string_key_value_pair_to_map(AMQP_VALUE map, const char* key, const char* value) |
Azure.IoT Build | 0:6ae2f7bca550 | 23 | { |
AzureIoTClient | 6:641a9672db08 | 24 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 25 | |
AzureIoTClient | 6:641a9672db08 | 26 | AMQP_VALUE key_value = amqpvalue_create_string(key); |
AzureIoTClient | 6:641a9672db08 | 27 | if (key == NULL) |
AzureIoTClient | 6:641a9672db08 | 28 | { |
AzureIoTClient | 6:641a9672db08 | 29 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 30 | } |
AzureIoTClient | 6:641a9672db08 | 31 | else |
AzureIoTClient | 6:641a9672db08 | 32 | { |
AzureIoTClient | 6:641a9672db08 | 33 | AMQP_VALUE value_value = amqpvalue_create_string(value); |
AzureIoTClient | 6:641a9672db08 | 34 | if (value_value == NULL) |
AzureIoTClient | 6:641a9672db08 | 35 | { |
AzureIoTClient | 6:641a9672db08 | 36 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 37 | } |
AzureIoTClient | 6:641a9672db08 | 38 | else |
AzureIoTClient | 6:641a9672db08 | 39 | { |
AzureIoTClient | 6:641a9672db08 | 40 | if (amqpvalue_set_map_value(map, key_value, value_value) != 0) |
AzureIoTClient | 6:641a9672db08 | 41 | { |
AzureIoTClient | 6:641a9672db08 | 42 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 43 | } |
AzureIoTClient | 6:641a9672db08 | 44 | else |
AzureIoTClient | 6:641a9672db08 | 45 | { |
AzureIoTClient | 6:641a9672db08 | 46 | result = 0; |
AzureIoTClient | 6:641a9672db08 | 47 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 48 | |
AzureIoTClient | 6:641a9672db08 | 49 | amqpvalue_destroy(key_value); |
AzureIoTClient | 6:641a9672db08 | 50 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 51 | |
AzureIoTClient | 6:641a9672db08 | 52 | amqpvalue_destroy(value_value); |
AzureIoTClient | 6:641a9672db08 | 53 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 54 | |
AzureIoTClient | 6:641a9672db08 | 55 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 56 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 57 | |
Azure.IoT Build | 0:6ae2f7bca550 | 58 | static int set_pending_operation_properties(MESSAGE_HANDLE message) |
Azure.IoT Build | 0:6ae2f7bca550 | 59 | { |
AzureIoTClient | 6:641a9672db08 | 60 | int result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 61 | |
AzureIoTClient | 6:641a9672db08 | 62 | PROPERTIES_HANDLE properties = properties_create(); |
AzureIoTClient | 6:641a9672db08 | 63 | if (properties == NULL) |
AzureIoTClient | 6:641a9672db08 | 64 | { |
AzureIoTClient | 6:641a9672db08 | 65 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 66 | } |
AzureIoTClient | 6:641a9672db08 | 67 | else |
AzureIoTClient | 6:641a9672db08 | 68 | { |
AzureIoTClient | 6:641a9672db08 | 69 | AMQP_VALUE reply_to = amqpvalue_create_address_string("cbs"); |
AzureIoTClient | 6:641a9672db08 | 70 | if (reply_to == NULL) |
AzureIoTClient | 6:641a9672db08 | 71 | { |
AzureIoTClient | 6:641a9672db08 | 72 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 73 | } |
AzureIoTClient | 6:641a9672db08 | 74 | else |
AzureIoTClient | 6:641a9672db08 | 75 | { |
AzureIoTClient | 6:641a9672db08 | 76 | if (properties_set_reply_to(properties, reply_to) != 0) |
AzureIoTClient | 6:641a9672db08 | 77 | { |
AzureIoTClient | 6:641a9672db08 | 78 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 79 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 80 | |
AzureIoTClient | 6:641a9672db08 | 81 | amqpvalue_destroy(reply_to); |
AzureIoTClient | 6:641a9672db08 | 82 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 83 | |
AzureIoTClient | 6:641a9672db08 | 84 | AMQP_VALUE message_id = amqpvalue_create_message_id_ulong(0x43); |
AzureIoTClient | 6:641a9672db08 | 85 | if (message_id == NULL) |
AzureIoTClient | 6:641a9672db08 | 86 | { |
AzureIoTClient | 6:641a9672db08 | 87 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 88 | } |
AzureIoTClient | 6:641a9672db08 | 89 | else |
AzureIoTClient | 6:641a9672db08 | 90 | { |
AzureIoTClient | 6:641a9672db08 | 91 | if (properties_set_message_id(properties, message_id) != 0) |
AzureIoTClient | 6:641a9672db08 | 92 | { |
AzureIoTClient | 6:641a9672db08 | 93 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 94 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 95 | |
AzureIoTClient | 6:641a9672db08 | 96 | amqpvalue_destroy(message_id); |
AzureIoTClient | 6:641a9672db08 | 97 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 98 | |
AzureIoTClient | 6:641a9672db08 | 99 | if (message_set_properties(message, properties) != 0) |
AzureIoTClient | 6:641a9672db08 | 100 | { |
AzureIoTClient | 6:641a9672db08 | 101 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 102 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 103 | |
AzureIoTClient | 6:641a9672db08 | 104 | properties_destroy(properties); |
AzureIoTClient | 6:641a9672db08 | 105 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 106 | |
AzureIoTClient | 6:641a9672db08 | 107 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 108 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 109 | |
Azure.IoT Build | 0:6ae2f7bca550 | 110 | CBS_HANDLE cbs_create(SESSION_HANDLE session, ON_AMQP_MANAGEMENT_STATE_CHANGED on_amqp_management_state_changed, void* callback_context) |
Azure.IoT Build | 0:6ae2f7bca550 | 111 | { |
AzureIoTClient | 6:641a9672db08 | 112 | CBS_INSTANCE* result; |
Azure.IoT Build | 0:6ae2f7bca550 | 113 | |
AzureIoTClient | 6:641a9672db08 | 114 | if (session == NULL) |
AzureIoTClient | 6:641a9672db08 | 115 | { |
AzureIoTClient | 6:641a9672db08 | 116 | result = NULL; |
AzureIoTClient | 6:641a9672db08 | 117 | } |
AzureIoTClient | 6:641a9672db08 | 118 | else |
AzureIoTClient | 6:641a9672db08 | 119 | { |
AzureIoTClient | 6:641a9672db08 | 120 | result = (CBS_INSTANCE*)amqpalloc_malloc(sizeof(CBS_INSTANCE)); |
AzureIoTClient | 6:641a9672db08 | 121 | if (result != NULL) |
AzureIoTClient | 6:641a9672db08 | 122 | { |
AzureIoTClient | 6:641a9672db08 | 123 | result->amqp_management = amqpmanagement_create(session, "$cbs", on_amqp_management_state_changed, callback_context); |
AzureIoTClient | 6:641a9672db08 | 124 | if (result->amqp_management == NULL) |
AzureIoTClient | 6:641a9672db08 | 125 | { |
AzureIoTClient | 6:641a9672db08 | 126 | amqpalloc_free(result); |
AzureIoTClient | 6:641a9672db08 | 127 | result = NULL; |
AzureIoTClient | 6:641a9672db08 | 128 | } |
AzureIoTClient | 6:641a9672db08 | 129 | } |
AzureIoTClient | 6:641a9672db08 | 130 | } |
AzureIoTClient | 6:641a9672db08 | 131 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 132 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 133 | |
Azure.IoT Build | 0:6ae2f7bca550 | 134 | void cbs_destroy(CBS_HANDLE cbs) |
Azure.IoT Build | 0:6ae2f7bca550 | 135 | { |
AzureIoTClient | 6:641a9672db08 | 136 | if (cbs != NULL) |
AzureIoTClient | 6:641a9672db08 | 137 | { |
AzureIoTClient | 6:641a9672db08 | 138 | (void)cbs_close(cbs); |
AzureIoTClient | 6:641a9672db08 | 139 | amqpmanagement_destroy(cbs->amqp_management); |
AzureIoTClient | 6:641a9672db08 | 140 | amqpalloc_free(cbs); |
AzureIoTClient | 6:641a9672db08 | 141 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 142 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 143 | |
Azure.IoT Build | 0:6ae2f7bca550 | 144 | int cbs_open(CBS_HANDLE cbs) |
Azure.IoT Build | 0:6ae2f7bca550 | 145 | { |
AzureIoTClient | 6:641a9672db08 | 146 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 147 | |
AzureIoTClient | 6:641a9672db08 | 148 | if (cbs == NULL) |
AzureIoTClient | 6:641a9672db08 | 149 | { |
AzureIoTClient | 6:641a9672db08 | 150 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 151 | } |
AzureIoTClient | 6:641a9672db08 | 152 | else |
AzureIoTClient | 6:641a9672db08 | 153 | { |
AzureIoTClient | 6:641a9672db08 | 154 | if (amqpmanagement_open(cbs->amqp_management) != 0) |
AzureIoTClient | 6:641a9672db08 | 155 | { |
AzureIoTClient | 6:641a9672db08 | 156 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 157 | } |
AzureIoTClient | 6:641a9672db08 | 158 | else |
AzureIoTClient | 6:641a9672db08 | 159 | { |
AzureIoTClient | 6:641a9672db08 | 160 | result = 0; |
AzureIoTClient | 6:641a9672db08 | 161 | } |
AzureIoTClient | 6:641a9672db08 | 162 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 163 | |
AzureIoTClient | 6:641a9672db08 | 164 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 165 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 166 | |
Azure.IoT Build | 0:6ae2f7bca550 | 167 | int cbs_close(CBS_HANDLE cbs) |
Azure.IoT Build | 0:6ae2f7bca550 | 168 | { |
AzureIoTClient | 6:641a9672db08 | 169 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 170 | |
AzureIoTClient | 6:641a9672db08 | 171 | if (cbs == NULL) |
AzureIoTClient | 6:641a9672db08 | 172 | { |
AzureIoTClient | 6:641a9672db08 | 173 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 174 | } |
AzureIoTClient | 6:641a9672db08 | 175 | else |
AzureIoTClient | 6:641a9672db08 | 176 | { |
AzureIoTClient | 6:641a9672db08 | 177 | if (amqpmanagement_close(cbs->amqp_management) != 0) |
AzureIoTClient | 6:641a9672db08 | 178 | { |
AzureIoTClient | 6:641a9672db08 | 179 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 180 | } |
AzureIoTClient | 6:641a9672db08 | 181 | else |
AzureIoTClient | 6:641a9672db08 | 182 | { |
AzureIoTClient | 6:641a9672db08 | 183 | result = 0; |
AzureIoTClient | 6:641a9672db08 | 184 | } |
AzureIoTClient | 6:641a9672db08 | 185 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 186 | |
AzureIoTClient | 6:641a9672db08 | 187 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 188 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 189 | |
Azure.IoT Build | 0:6ae2f7bca550 | 190 | int cbs_put_token(CBS_HANDLE cbs, const char* type, const char* audience, const char* token, ON_CBS_OPERATION_COMPLETE on_operation_complete, void* context) |
Azure.IoT Build | 0:6ae2f7bca550 | 191 | { |
AzureIoTClient | 6:641a9672db08 | 192 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 193 | |
AzureIoTClient | 6:641a9672db08 | 194 | if ((cbs == NULL) || |
AzureIoTClient | 6:641a9672db08 | 195 | (token == NULL)) |
AzureIoTClient | 6:641a9672db08 | 196 | { |
AzureIoTClient | 6:641a9672db08 | 197 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 198 | } |
AzureIoTClient | 6:641a9672db08 | 199 | else |
AzureIoTClient | 6:641a9672db08 | 200 | { |
AzureIoTClient | 6:641a9672db08 | 201 | MESSAGE_HANDLE message = message_create(); |
AzureIoTClient | 6:641a9672db08 | 202 | if (message == NULL) |
AzureIoTClient | 6:641a9672db08 | 203 | { |
AzureIoTClient | 6:641a9672db08 | 204 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 205 | } |
AzureIoTClient | 6:641a9672db08 | 206 | else |
AzureIoTClient | 6:641a9672db08 | 207 | { |
AzureIoTClient | 6:641a9672db08 | 208 | AMQP_VALUE token_value = amqpvalue_create_string(token); |
AzureIoTClient | 6:641a9672db08 | 209 | if (token_value == NULL) |
AzureIoTClient | 6:641a9672db08 | 210 | { |
AzureIoTClient | 6:641a9672db08 | 211 | message_destroy(message); |
AzureIoTClient | 6:641a9672db08 | 212 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 213 | } |
AzureIoTClient | 6:641a9672db08 | 214 | else |
AzureIoTClient | 6:641a9672db08 | 215 | { |
AzureIoTClient | 6:641a9672db08 | 216 | if (message_set_body_amqp_value(message, token_value) != 0) |
AzureIoTClient | 6:641a9672db08 | 217 | { |
AzureIoTClient | 6:641a9672db08 | 218 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 219 | } |
AzureIoTClient | 6:641a9672db08 | 220 | else |
AzureIoTClient | 6:641a9672db08 | 221 | { |
AzureIoTClient | 6:641a9672db08 | 222 | AMQP_VALUE application_properties = amqpvalue_create_map(); |
AzureIoTClient | 6:641a9672db08 | 223 | if (application_properties == NULL) |
AzureIoTClient | 6:641a9672db08 | 224 | { |
AzureIoTClient | 6:641a9672db08 | 225 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 226 | } |
AzureIoTClient | 6:641a9672db08 | 227 | else |
AzureIoTClient | 6:641a9672db08 | 228 | { |
AzureIoTClient | 6:641a9672db08 | 229 | if (add_string_key_value_pair_to_map(application_properties, "name", audience) != 0) |
AzureIoTClient | 6:641a9672db08 | 230 | { |
AzureIoTClient | 6:641a9672db08 | 231 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 232 | } |
AzureIoTClient | 6:641a9672db08 | 233 | else |
AzureIoTClient | 6:641a9672db08 | 234 | { |
AzureIoTClient | 6:641a9672db08 | 235 | if (message_set_application_properties(message, application_properties) != 0) |
AzureIoTClient | 6:641a9672db08 | 236 | { |
AzureIoTClient | 6:641a9672db08 | 237 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 238 | } |
AzureIoTClient | 6:641a9672db08 | 239 | else |
AzureIoTClient | 6:641a9672db08 | 240 | { |
AzureIoTClient | 6:641a9672db08 | 241 | if (set_pending_operation_properties(message) != 0) |
AzureIoTClient | 6:641a9672db08 | 242 | { |
AzureIoTClient | 6:641a9672db08 | 243 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 244 | } |
AzureIoTClient | 6:641a9672db08 | 245 | else |
AzureIoTClient | 6:641a9672db08 | 246 | { |
AzureIoTClient | 6:641a9672db08 | 247 | if (amqpmanagement_start_operation(cbs->amqp_management, "put-token", type, NULL, message, (ON_OPERATION_COMPLETE)on_operation_complete, context) != 0) |
AzureIoTClient | 6:641a9672db08 | 248 | { |
AzureIoTClient | 6:641a9672db08 | 249 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 250 | } |
AzureIoTClient | 6:641a9672db08 | 251 | else |
AzureIoTClient | 6:641a9672db08 | 252 | { |
AzureIoTClient | 6:641a9672db08 | 253 | result = 0; |
AzureIoTClient | 6:641a9672db08 | 254 | } |
AzureIoTClient | 6:641a9672db08 | 255 | } |
AzureIoTClient | 6:641a9672db08 | 256 | } |
AzureIoTClient | 6:641a9672db08 | 257 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 258 | |
AzureIoTClient | 6:641a9672db08 | 259 | amqpvalue_destroy(application_properties); |
AzureIoTClient | 6:641a9672db08 | 260 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 261 | |
AzureIoTClient | 6:641a9672db08 | 262 | amqpvalue_destroy(token_value); |
AzureIoTClient | 6:641a9672db08 | 263 | } |
AzureIoTClient | 6:641a9672db08 | 264 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 265 | |
AzureIoTClient | 6:641a9672db08 | 266 | message_destroy(message); |
AzureIoTClient | 6:641a9672db08 | 267 | } |
AzureIoTClient | 6:641a9672db08 | 268 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 269 | |
AzureIoTClient | 6:641a9672db08 | 270 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 271 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 272 | |
Azure.IoT Build | 0:6ae2f7bca550 | 273 | int cbs_delete_token(CBS_HANDLE cbs, const char* type, const char* audience, ON_CBS_OPERATION_COMPLETE on_operation_complete, void* context) |
Azure.IoT Build | 0:6ae2f7bca550 | 274 | { |
AzureIoTClient | 6:641a9672db08 | 275 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 276 | |
AzureIoTClient | 6:641a9672db08 | 277 | if (cbs == NULL) |
AzureIoTClient | 6:641a9672db08 | 278 | { |
AzureIoTClient | 6:641a9672db08 | 279 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 280 | } |
AzureIoTClient | 6:641a9672db08 | 281 | else |
AzureIoTClient | 6:641a9672db08 | 282 | { |
AzureIoTClient | 6:641a9672db08 | 283 | MESSAGE_HANDLE message = message_create(); |
AzureIoTClient | 6:641a9672db08 | 284 | if (message == NULL) |
AzureIoTClient | 6:641a9672db08 | 285 | { |
AzureIoTClient | 6:641a9672db08 | 286 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 287 | } |
AzureIoTClient | 6:641a9672db08 | 288 | else |
AzureIoTClient | 6:641a9672db08 | 289 | { |
AzureIoTClient | 6:641a9672db08 | 290 | AMQP_VALUE application_properties = amqpvalue_create_map(); |
AzureIoTClient | 6:641a9672db08 | 291 | if (application_properties == NULL) |
AzureIoTClient | 6:641a9672db08 | 292 | { |
AzureIoTClient | 6:641a9672db08 | 293 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 294 | } |
AzureIoTClient | 6:641a9672db08 | 295 | else |
AzureIoTClient | 6:641a9672db08 | 296 | { |
AzureIoTClient | 6:641a9672db08 | 297 | if (add_string_key_value_pair_to_map(application_properties, "name", audience) != 0) |
AzureIoTClient | 6:641a9672db08 | 298 | { |
AzureIoTClient | 6:641a9672db08 | 299 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 300 | } |
AzureIoTClient | 6:641a9672db08 | 301 | else |
AzureIoTClient | 6:641a9672db08 | 302 | { |
AzureIoTClient | 6:641a9672db08 | 303 | if (message_set_application_properties(message, application_properties) != 0) |
AzureIoTClient | 6:641a9672db08 | 304 | { |
AzureIoTClient | 6:641a9672db08 | 305 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 306 | } |
AzureIoTClient | 6:641a9672db08 | 307 | else |
AzureIoTClient | 6:641a9672db08 | 308 | { |
AzureIoTClient | 6:641a9672db08 | 309 | if (set_pending_operation_properties(message) != 0) |
AzureIoTClient | 6:641a9672db08 | 310 | { |
AzureIoTClient | 6:641a9672db08 | 311 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 312 | } |
AzureIoTClient | 6:641a9672db08 | 313 | else |
AzureIoTClient | 6:641a9672db08 | 314 | { |
AzureIoTClient | 6:641a9672db08 | 315 | if (amqpmanagement_start_operation(cbs->amqp_management, "delete-token", type, NULL, message, (ON_OPERATION_COMPLETE)on_operation_complete, context) != 0) |
AzureIoTClient | 6:641a9672db08 | 316 | { |
AzureIoTClient | 6:641a9672db08 | 317 | result = __LINE__; |
AzureIoTClient | 6:641a9672db08 | 318 | } |
AzureIoTClient | 6:641a9672db08 | 319 | else |
AzureIoTClient | 6:641a9672db08 | 320 | { |
AzureIoTClient | 6:641a9672db08 | 321 | result = 0; |
AzureIoTClient | 6:641a9672db08 | 322 | } |
AzureIoTClient | 6:641a9672db08 | 323 | } |
AzureIoTClient | 6:641a9672db08 | 324 | } |
AzureIoTClient | 6:641a9672db08 | 325 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 326 | |
AzureIoTClient | 6:641a9672db08 | 327 | amqpvalue_destroy(application_properties); |
AzureIoTClient | 6:641a9672db08 | 328 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 329 | |
AzureIoTClient | 6:641a9672db08 | 330 | message_destroy(message); |
AzureIoTClient | 6:641a9672db08 | 331 | } |
AzureIoTClient | 6:641a9672db08 | 332 | } |
AzureIoTClient | 6:641a9672db08 | 333 | return result; |
AzureIoTClient | 6:641a9672db08 | 334 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 335 | |
AzureIoTClient | 6:641a9672db08 | 336 | void cbs_set_trace(CBS_HANDLE cbs, bool traceOn) |
AzureIoTClient | 6:641a9672db08 | 337 | { |
AzureIoTClient | 6:641a9672db08 | 338 | if (cbs != NULL) |
AzureIoTClient | 6:641a9672db08 | 339 | { |
AzureIoTClient | 6:641a9672db08 | 340 | amqpmanagement_set_trace(cbs->amqp_management, traceOn); |
AzureIoTClient | 6:641a9672db08 | 341 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 342 | } |