bool ClientV2::UpdateCommandExecution()

in commands/source/IotCommandsClientV2.cpp [121:190]


        bool ClientV2::UpdateCommandExecution(
            const UpdateCommandExecutionRequest &request,
            const UpdateCommandExecutionResultHandler &handler)
        {
            Aws::Crt::StringStream publishTopicStream;
            publishTopicStream << "$aws/commands/" << DeviceTypeMarshaller::ToString(*request.DeviceType) << "/"
                               << *request.DeviceId << "/executions/" << *request.ExecutionId << "/response/json";
            Aws::Crt::String publishTopic = publishTopicStream.str();

            Aws::Crt::StringStream subscriptionTopicStream0;
            subscriptionTopicStream0 << "$aws/commands/" << DeviceTypeMarshaller::ToString(*request.DeviceType) << "/"
                                     << *request.DeviceId << "/executions/" << *request.ExecutionId
                                     << "/response/accepted/json";
            Aws::Crt::String subscriptionTopic0 = subscriptionTopicStream0.str();

            Aws::Crt::StringStream subscriptionTopicStream1;
            subscriptionTopicStream1 << "$aws/commands/" << DeviceTypeMarshaller::ToString(*request.DeviceType) << "/"
                                     << *request.DeviceId << "/executions/" << *request.ExecutionId
                                     << "/response/rejected/json";
            Aws::Crt::String subscriptionTopic1 = subscriptionTopicStream1.str();

            struct aws_byte_cursor subscriptionTopicFilters[2] = {
                Aws::Crt::ByteCursorFromString(subscriptionTopic0),
                Aws::Crt::ByteCursorFromString(subscriptionTopic1),
            };

            Aws::Crt::StringStream responsePathTopicAcceptedStream;
            responsePathTopicAcceptedStream << "$aws/commands/" << DeviceTypeMarshaller::ToString(*request.DeviceType)
                                            << "/" << *request.DeviceId << "/executions/" << *request.ExecutionId
                                            << "/response/accepted/json";
            Aws::Crt::String responsePathTopicAccepted = responsePathTopicAcceptedStream.str();

            Aws::Crt::StringStream responsePathTopicRejectedStream;
            responsePathTopicRejectedStream << "$aws/commands/" << DeviceTypeMarshaller::ToString(*request.DeviceType)
                                            << "/" << *request.DeviceId << "/executions/" << *request.ExecutionId
                                            << "/response/rejected/json";
            Aws::Crt::String responsePathTopicRejected = responsePathTopicRejectedStream.str();

            struct aws_mqtt_request_operation_response_path responsePaths[2];
            responsePaths[0].topic = Aws::Crt::ByteCursorFromString(responsePathTopicAccepted);
            responsePaths[1].topic = Aws::Crt::ByteCursorFromString(responsePathTopicRejected);
            AWS_ZERO_STRUCT(responsePaths[0].correlation_token_json_path);
            AWS_ZERO_STRUCT(responsePaths[1].correlation_token_json_path);

            Aws::Crt::JsonObject jsonObject;
            request.SerializeToObject(jsonObject);

            Aws::Crt::String outgoingJson = jsonObject.View().WriteCompact(true);

            struct aws_mqtt_request_operation_options options;
            AWS_ZERO_STRUCT(options);
            options.subscription_topic_filters = subscriptionTopicFilters;
            options.subscription_topic_filter_count = 2;
            options.response_paths = responsePaths;
            options.response_path_count = 2;
            options.publish_topic = Aws::Crt::ByteCursorFromString(publishTopic);
            options.serialized_request =
                Aws::Crt::ByteCursorFromArray((uint8_t *)outgoingJson.data(), outgoingJson.length());

            auto resultHandler = [handler, responsePathTopicAccepted, responsePathTopicRejected](
                                     Aws::Iot::RequestResponse::UnmodeledResult &&result)
            {
                s_UpdateCommandExecutionResponseHandler(
                    std::move(result), handler, responsePathTopicAccepted, responsePathTopicRejected);
            };

            int submitResult = m_bindingClient->SubmitRequest(options, std::move(resultHandler));

            return submitResult == AWS_OP_SUCCESS;
        }