Skip to content
Snippets Groups Projects
Commit 8b90c473 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

proxy server: add logs

parent fae6b138
Branches
Tags
No related merge requests found
...@@ -360,6 +360,8 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session) ...@@ -360,6 +360,8 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session)
auto isAndroid = platform == "android"; auto isAndroid = platform == "android";
auto clientId = root.isMember("client_id") ? root["client_id"].asString() : std::string(); auto clientId = root.isMember("client_id") ? root["client_id"].asString() : std::string();
std::cout << "Subscribe " << infoHash << " token:" << tokenFromReq << " client:" << clientId << std::endl;
{ {
std::lock_guard<std::mutex> lock(lockListener_); std::lock_guard<std::mutex> lock(lockListener_);
// Check if listener is already present and refresh timeout if launched // Check if listener is already present and refresh timeout if launched
...@@ -578,6 +580,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session) ...@@ -578,6 +580,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session)
// Build the Value from json // Build the Value from json
auto value = std::make_shared<Value>(root); auto value = std::make_shared<Value>(root);
auto permanent = root.isMember("permanent"); auto permanent = root.isMember("permanent");
std::cout << "Got put " << infoHash << " " << value << " " << (permanent ? "permanent" : "") << std::endl;
if (permanent) { if (permanent) {
std::string pushToken, clientId, platform; std::string pushToken, clientId, platform;
...@@ -596,6 +599,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session) ...@@ -596,6 +599,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session)
auto r = sPuts->second.puts.emplace(vid, PermanentPut{}); auto r = sPuts->second.puts.emplace(vid, PermanentPut{});
if (r.second) { if (r.second) {
r.first->second.expireJob = scheduler_.add(timeout, [this, infoHash, vid]{ r.first->second.expireJob = scheduler_.add(timeout, [this, infoHash, vid]{
std::cout << "Permanent put expired" << infoHash << std::endl;
cancelPut(infoHash, vid); cancelPut(infoHash, vid);
}); });
#if OPENDHT_PUSH_NOTIFICATIONS #if OPENDHT_PUSH_NOTIFICATIONS
...@@ -603,6 +607,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session) ...@@ -603,6 +607,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session)
r.first->second.expireNotifyJob = scheduler_.add(timeout - proxy::OP_MARGIN, r.first->second.expireNotifyJob = scheduler_.add(timeout - proxy::OP_MARGIN,
[this, infoHash, vid, pushToken, clientId, isAndroid] [this, infoHash, vid, pushToken, clientId, isAndroid]
{ {
std::cout << "Permanent put refresh" << infoHash << std::endl;
Json::Value json; Json::Value json;
json["timeout"] = infoHash.toString(); json["timeout"] = infoHash.toString();
json["to"] = clientId; json["to"] = clientId;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment