How to determine (on the server side) that the remote client disconnects during a very long polling REST request?
something like this:
Data waitForUpdatedData(...) {
Nullable!bool ready;
Data result;
auto disconnectionTask = runTask({
waitForClientDisconnection(); /// ????
ready = false;
endCondition.notify();
});
auto workerTask = runTask({
result = waitingForUpdates();
ready = true;
endCondition.notify();
});
while(ready.isNull) endCondition.wait();
if(ready) disconnectionTask.terminate();
else workerTask.terminate();
return result;
}