in docker_images/c/wrapper/glue/ModuleGlue.cpp [94:127]
std::string ModuleGlue::WaitForInputMessage(std::string connectionId, std::string inputName)
{
IOTHUB_CLIENT_RESULT ret;
std::cout << "ModuleGlue::WaitForInputMessage for " << connectionId << " and " << inputName << std::endl;
IOTHUB_MODULE_CLIENT_HANDLE client = (IOTHUB_MODULE_CLIENT_HANDLE)this->clientMap[connectionId];
if (!client)
{
throw new std::runtime_error("client is not opened");
}
message_response_struct resp;
ret = IoTHubModuleClient_SetInputMessageCallback(client, inputName.c_str(), receiveMessageCallback, &resp);
ThrowIfFailed(ret, "IoTHubModuleClient_SetInputMessageCallback");
std::cout << "waiting for input message" << std::endl;
try
{
std::unique_lock<std::mutex> lk(resp.m);
resp.cv.wait(lk);
}
catch (...)
{
ret = IoTHubModuleClient_SetInputMessageCallback(client, inputName.c_str(), NULL, NULL);
ThrowIfFailed(ret, "IoTHubModuleClient_SetInputMessageCallback(NULL)");
throw;
}
std::cout << "input message received" << std::endl;
ret = IoTHubModuleClient_SetInputMessageCallback(client, inputName.c_str(), NULL, NULL);
ThrowIfFailed(ret, "IoTHubModuleClient_SetInputMessageCallback(NULL)");
return addJsonWrapperObject(resp.response_string, "body");
}