fix json notifications

This commit is contained in:
badaix 2017-01-31 21:49:41 +01:00
parent 94eb840f50
commit 1c4fad8f46
2 changed files with 11 additions and 11 deletions

2
externals/jsonrpcpp vendored

@ -1 +1 @@
Subproject commit df2084d291100eb6744c01deb3aff36048100ec2 Subproject commit d966281acc97f69dd47017bb8d9b94f002202dae

View file

@ -43,7 +43,7 @@ void StreamServer::onStateChanged(const PcmStream* pcmStream, const ReaderState&
{ {
logO << "onStateChanged (" << pcmStream->getName() << "): " << state << "\n"; logO << "onStateChanged (" << pcmStream->getName() << "): " << state << "\n";
// logO << pcmStream->toJson().dump(4); // logO << pcmStream->toJson().dump(4);
json notification = jsonrpcpp::Notification("Stream.OnUpdate", Json({"data", pcmStream->toJson()})).to_json(); json notification = jsonrpcpp::Notification("Stream.OnUpdate", pcmStream->toJson()).to_json();
controlServer_->send(notification.dump(), NULL); controlServer_->send(notification.dump(), NULL);
} }
@ -99,7 +99,7 @@ void StreamServer::onDisconnect(StreamSession* streamSession)
Config::instance().save(); Config::instance().save();
if (controlServer_ != nullptr) if (controlServer_ != nullptr)
{ {
json notification = jsonrpcpp::Notification("Client.OnDisconnect", Json({"data", clientInfo->toJson()})).to_json(); json notification = jsonrpcpp::Notification("Client.OnDisconnect", clientInfo->toJson()).to_json();
controlServer_->send(notification.dump()); controlServer_->send(notification.dump());
} }
} }
@ -112,7 +112,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
jsonrpcpp::Request request; jsonrpcpp::Request request;
try try
{ {
request.parse(Json::parse(message)); request.parse(message);
logO << "method: " << request.method << ", " << "id: " << request.id << "\n"; logO << "method: " << request.method << ", " << "id: " << request.id << "\n";
json result; json result;
@ -166,7 +166,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
} }
/// Notify others /// Notify others
json notification = jsonrpcpp::Notification("Client.OnUpdate", Json({"data", clientInfo->toJson()})).to_json(); json notification = jsonrpcpp::Notification("Client.OnUpdate", clientInfo->toJson()).to_json();
logO << "Notification: " << notification.dump() << "\n"; logO << "Notification: " << notification.dump() << "\n";
controlServer_->send(notification.dump(), controlSession); controlServer_->send(notification.dump(), controlSession);
} }
@ -205,7 +205,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
} }
/// Notify others /// Notify others
json notification = jsonrpcpp::Notification("Group.OnUpdate", Json({"data", group->toJson()})).to_json(); json notification = jsonrpcpp::Notification("Group.OnUpdate", group->toJson()).to_json();
logO << "Notification: " << notification.dump() << "\n"; logO << "Notification: " << notification.dump() << "\n";
controlServer_->send(notification.dump(), controlSession); controlServer_->send(notification.dump(), controlSession);
} }
@ -264,7 +264,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
result = {{"method", "Server.OnUpdate"}, {"params", serverJson}}; result = {{"method", "Server.OnUpdate"}, {"params", serverJson}};
/// Notify others: since at least two groups are affected, send a complete server update /// Notify others: since at least two groups are affected, send a complete server update
json notification = jsonrpcpp::Notification("Server.OnUpdate", Json({"data", serverJson})).to_json(); json notification = jsonrpcpp::Notification("Server.OnUpdate", serverJson).to_json();
logO << "Notification: " << notification.dump() << "\n"; logO << "Notification: " << notification.dump() << "\n";
controlServer_->send(notification.dump(), controlSession); controlServer_->send(notification.dump(), controlSession);
} }
@ -289,7 +289,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
result = {{"method", "Server.OnUpdate"}, {"params", serverJson}}; result = {{"method", "Server.OnUpdate"}, {"params", serverJson}};
/// Notify others /// Notify others
json notification = jsonrpcpp::Notification("Server.OnUpdate", Json({"data", serverJson})).to_json(); json notification = jsonrpcpp::Notification("Server.OnUpdate", serverJson).to_json();
logO << "Notification: " << notification.dump() << "\n"; logO << "Notification: " << notification.dump() << "\n";
controlServer_->send(notification.dump(), controlSession); controlServer_->send(notification.dump(), controlSession);
} }
@ -399,13 +399,13 @@ void StreamServer::onMessageReceived(StreamSession* connection, const msg::BaseM
if (newGroup) if (newGroup)
{ {
json serverJson = Config::instance().getServerStatus(streamManager_->toJson()); json serverJson = Config::instance().getServerStatus(streamManager_->toJson());
json notification = jsonrpcpp::Notification("Server.OnUpdate", Json({"data", serverJson})).to_json(); json notification = jsonrpcpp::Notification("Server.OnUpdate", serverJson).to_json();
controlServer_->send(notification.dump()); controlServer_->send(notification.dump());
} }
else else
{ {
json notification = jsonrpcpp::Notification("Client.OnConnect", Json({"data", client->toJson()})).to_json(); json notification = jsonrpcpp::Notification("Client.OnConnect", client->toJson()).to_json();
//logO << notification.dump(4) << "\n"; // logO << notification.dump(4) << "\n";
controlServer_->send(notification.dump()); controlServer_->send(notification.dump());
} }
// cout << Config::instance().getServerStatus(streamManager_->toJson()).dump(4) << "\n"; // cout << Config::instance().getServerStatus(streamManager_->toJson()).dump(4) << "\n";