dhtproxy: remove sendSubscribe

This commit is contained in:
Sébastien Blin authored and Adrien Béraud committed 2019-01-14 10:53:08 -08:00
1 parent 70f09ded3f
commit 3a3933e6d5
3 files changed
+23 -96

No files matched your search

+3 -4
View File
@@ -287,7 +287,7 @@ DhtProxyServer::get(const Sp<restbed::Session>& session) const
Json::StreamWriterBuilder wbuilder;
wbuilder["commentStyle"] = "None";
wbuilder["indentation"] = "";
auto output = Json::writeString(wbuilder, value->toJson()) + "\n";
auto output = Json::writeString(wbuilder, value->toJson()) + "\n";
s->yield(output, [](const Sp<restbed::Session>& /*session*/){ });
return true;
}, [s](bool /*ok* */) {
@@ -428,6 +428,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session)
if (listener.clientId == clientId) {
scheduler_.edit(listener.expireJob, timeout);
scheduler_.edit(listener.expireNotifyJob, timeout - proxy::OP_MARGIN);
s->yield(restbed::OK);
dht_->get(infoHash,
[this, s](const Sp<Value>& value) {
if (s->is_closed()) return false;
@@ -441,8 +442,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session)
}, [s](bool /*ok* */) {
// Communication is finished
if (not s->is_closed()) {
std::cout << "X: " << std::endl;
s->close();
s->close("{}\n");
}
});
schedulerCv_.notify_one();
@@ -483,7 +483,6 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session)
);
}
schedulerCv_.notify_one();
std::cout << "CLOSE: " << std::endl;
s->close(restbed::OK, "{}\n");
} catch (...) {
s->close(restbed::INTERNAL_SERVER_ERROR, "{\"err\":\"Internal server error\"}");