in docker_images/c/wrapper/glue/InternalGlue.cpp [297:326]
void InternalGlue::WaitForMethodAndReturnResponse(std::string connectionId, std::string methodName, std::string requestAndResponse)
{
IOTHUB_CLIENT_RESULT ret;
std::cout << "InternalGlue::WaitForMethodAndReturnResponse for " << connectionId << " and " << methodName << std::endl;
IOTHUB_CLIENT_CORE_HANDLE client = (IOTHUB_CLIENT_CORE_HANDLE)this->clientMap[connectionId];
if (!client)
{
throw new std::runtime_error("client is not opened");
}
std::string expectedRequest, response;
int statusCode;
parseMethodRequestAndResponse(requestAndResponse, &expectedRequest, &response, &statusCode);
method_callback_struct cb_data;
cb_data.expected_method_name = methodName;
cb_data.expected_request_payload = expectedRequest;
cb_data.response = response;
cb_data.status_code = statusCode;
ret = IoTHubClientCore_SetDeviceMethodCallback(client, methodCallback, &cb_data);
ThrowIfFailed(ret, "IoTHubClientCore_SetDeviceMethodCallback");
std::cout << "waiting for method call" << std::endl;
{
std::unique_lock<std::mutex> lk(cb_data.m);
cb_data.cv.wait(lk);
}
std::cout << "method call received" << std::endl;
}