Hi Tish,
I am sorry for my late reply. This project involves a lot of other things that needed some attention.
The thing is, that I have still not found a solution to this. To be very honest I haven’t researched it in depth to solve it.
To overcome this problem I have used a different architecture on the client side using callbacks.
The client now has to act as a server as well.
Whenever a client makes a call to the server it now has to pass a callback url. Whenever my action is complete my server acts as a client a makes a call to this callback url.
For example:
- The client makes a call to my server like this:
http://10.32.456.27:1715/something/A/B/C?callbackurl=http://10.34.444.32:837474/D/F/V
2.The server catches this and does some magic with moving cameras around. This can take up to a few seconds.
So in the handleRequest I create a pointer to a class that keeps listening for the events when the cameras are in place:
void NCHandlePreapreCameraWithPreset::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response) {
response.setContentType("application/json");
response.setKeepAlive(true);
//get all the stuff you need from the clients request
//id, temppresetid, callbackurl and so on.
NCCallBackManager *manager = new NCCallBackManager();
manager->startListeningForCamPanTiltZoom(id, temppresetid,_callbackurl, manager->REGULAR_PRESET);
response.send();
}
Notice that the class NCCallBackManager is not deleted here.
It deletes itself once it’s works is done. That is definitely not the best way to handle this, but for now it works…
3.When this CallBackManager class receives the incoming event that the cameras are done it acts as a client and use the callbackurl to notify the client/server on the other side that the work is done.
Poco::URI uri(thisisthecallbackurl);
Poco::Net::HTTPClientSession client_session(uri.getHost(), uri.getPort());
//Prepare and send request
string path(uri.getPathAndQuery());
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, path, Poco::Net::HTTPMessage::HTTP_1_1);
client_session.sendRequest(req);
Now this implementation is a serious detour just to make things work.
I still haven’t figured out how to make HTTPServerResponse wait for other tasks without being destroyed first. I have to admit I am not very skilled in threading and going deep into the core Poco threading/server stuff…
I hope you may have found an answer to this or have found at least a road that is pointing in the right direction 
Thanks.