diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h index 56f0e7fc256c8ab57dc619ef8e7a4c7eefefe7b7..a9552d8e7a4affbebb256498dd28763cb833d24f 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 8860db5db714a724c48c90508af13f3eff160191..ab7b7326a8625b73a1c29d41cd81e6cc39728204 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