diff --git a/src/shadow/src/shadow_client.c b/src/shadow/src/shadow_client.c index 492c865..be7bad4 100644 --- a/src/shadow/src/shadow_client.c +++ b/src/shadow/src/shadow_client.c @@ -45,7 +45,6 @@ void* IOT_Shadow_Construct(const char *product_sn, const char *device_sn, void * UIoT_Client *mqtt_client = (UIoT_Client *)ch_signal; - mqtt_client->event_handler.context = shadow_client; shadow_client->product_sn = product_sn; shadow_client->device_sn = device_sn; shadow_client->mqtt = mqtt_client; diff --git a/src/shadow/src/shadow_client_manager.c b/src/shadow/src/shadow_client_manager.c index e978d93..08df58e 100644 --- a/src/shadow/src/shadow_client_manager.c +++ b/src/shadow/src/shadow_client_manager.c @@ -285,6 +285,7 @@ int uiot_shadow_subscribe_topic(UIoT_Shadow *pShadow, char *topicFilter, OnMessa SubscribeParams subscribe_params = DEFAULT_SUB_PARAMS; subscribe_params.on_message_handler = on_message_handler; + subscribe_params.user_data = pShadow; subscribe_params.qos = QOS1; ret = IOT_MQTT_Subscribe(mqtt_client, topic_name, &subscribe_params); @@ -637,8 +638,7 @@ void topic_request_result_handler(void *pClient, MQTTMessage *message, void *pUs POINTER_VALID_CHECK_RTN(pClient); POINTER_VALID_CHECK_RTN(message); - UIoT_Client *mqtt_client = (UIoT_Client *)pClient; - UIoT_Shadow *shadow_client = (UIoT_Shadow*)mqtt_client->event_handler.context; + UIoT_Shadow *shadow_client = (UIoT_Shadow*)pUserdata; const char *topic = message->topic; size_t topic_len = message->topic_len; @@ -738,8 +738,7 @@ void topic_sync_handler(void *pClient, MQTTMessage *message, void *pUserdata) POINTER_VALID_CHECK_RTN(pClient); POINTER_VALID_CHECK_RTN(message); - UIoT_Client *mqtt_client = (UIoT_Client *)pClient; - UIoT_Shadow *shadow_client = (UIoT_Shadow*)mqtt_client->event_handler.context; + UIoT_Shadow *shadow_client = (UIoT_Shadow*)pUserdata; const char *topic = message->topic; size_t topic_len = message->topic_len;