From aa93db4fa62ccb1138b9c0c6e3a4b350fd3cc52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 19 Feb 2019 02:11:59 -0500 Subject: [PATCH] proxy server: move json to sendPushNotification --- include/opendht/dht_proxy_server.h | 2 +- src/dht_proxy_server.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h index 56f0e7fc..a9552d8e 100644 --- a/include/opendht/dht_proxy_server.h +++ b/include/opendht/dht_proxy_server.h @@ -253,7 +253,7 @@ private: * @param key of the device * @param json, the content to send */ - void sendPushNotification(const std::string& key, const Json::Value& json, bool isAndroid) const; + void sendPushNotification(const std::string& key, Json::Value&& json, bool isAndroid) const; /** * Remove a push listener between a client and a hash diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index 8860db5d..ab7b7326 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -478,7 +478,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session) Json::Value json; json["key"] = infoHash.toString(); json["to"] = clientId; - sendPushNotification(pushToken, json, isAndroid); + sendPushNotification(pushToken, std::move(json), isAndroid); return true; } ); @@ -493,7 +493,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session) Json::Value json; json["timeout"] = infoHash.toString(); json["to"] = clientId; - sendPushNotification(pushToken, json, isAndroid); + sendPushNotification(pushToken, std::move(json), isAndroid); } ); } @@ -571,7 +571,7 @@ DhtProxyServer::cancelPushListen(const std::string& pushToken, const dht::InfoHa } void -DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value& json, bool isAndroid) const +DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& json, bool isAndroid) const { if (pushServer_.empty()) return; @@ -583,9 +583,9 @@ DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value Json::Value notification(Json::objectValue); Json::Value tokens(Json::arrayValue); tokens[0] = token; - notification["tokens"] = tokens; + notification["tokens"] = std::move(tokens); notification["platform"] = isAndroid ? 2 : 1; - notification["data"] = json; + notification["data"] = std::move(json); notification["priority"] = "high"; notification["time_to_live"] = 600; @@ -593,7 +593,7 @@ DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value notifications[0] = notification; Json::Value content; - content["notifications"] = notifications; + content["notifications"] = std::move(notifications); Json::StreamWriterBuilder wbuilder; wbuilder["commentStyle"] = "None"; @@ -694,7 +694,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session) json["timeout"] = infoHash.toString(); json["to"] = clientId; json["vid"] = std::to_string(vid); - sendPushNotification(pushToken, json, isAndroid); + sendPushNotification(pushToken, std::move(json), isAndroid); }); } #endif -- GitLab