From 0b69bf2ff39c5475b580f63d7b8062798201d0de Mon Sep 17 00:00:00 2001 From: badaix Date: Sat, 25 Feb 2017 10:46:23 +0100 Subject: [PATCH] small RPC API change --- .../de/badaix/snapcast/control/RemoteControl.java | 10 +++++----- server/streamServer.cpp | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/android/Snapcast/src/main/java/de/badaix/snapcast/control/RemoteControl.java b/android/Snapcast/src/main/java/de/badaix/snapcast/control/RemoteControl.java index 7f046b8a..a049ba6c 100644 --- a/android/Snapcast/src/main/java/de/badaix/snapcast/control/RemoteControl.java +++ b/android/Snapcast/src/main/java/de/badaix/snapcast/control/RemoteControl.java @@ -144,21 +144,21 @@ public class RemoteControl implements TcpClient.TcpClientListener { RPCEvent rpcEvent = RPCEvent.response; /// Response to a "Object.GetStatus" message if (request.method.equals("Client.GetStatus")) { - listener.onUpdate(new Client(json.getJSONObject("result"))); + listener.onUpdate(new Client(response.result.getJSONObject("client"))); } else if (request.method.equals("Client.SetVolume")) { } else if (request.method.equals("Client.SetLatency")) { } else if (request.method.equals("Client.SetName")) { } else if (request.method.equals("Group.GetStatus")) { - listener.onUpdate(new Group(json.getJSONObject("result"))); + listener.onUpdate(new Group(response.result.getJSONObject("group"))); } else if (request.method.equals("Group.SetMute")) { // listener.onMute(rpcEvent, request.params.getString("id"), response.result.getBoolean("mute")); } else if (request.method.equals("Group.SetStream")) { } else if (request.method.equals("Group.SetClients")) { - listener.onUpdate(new ServerStatus(json.getJSONObject("result").getJSONObject("server"))); + listener.onUpdate(new ServerStatus(response.result.getJSONObject("server"))); } else if (request.method.equals("Server.GetStatus")) { - listener.onUpdate(new ServerStatus(json.getJSONObject("result"))); + listener.onUpdate(new ServerStatus(response.result.getJSONObject("server"))); } else if (request.method.equals("Server.DeleteClient")) { - listener.onUpdate(new ServerStatus(json.getJSONObject("result").getJSONObject("server"))); + listener.onUpdate(new ServerStatus(response.result.getJSONObject("server"))); } } else { /// Notification diff --git a/server/streamServer.cpp b/server/streamServer.cpp index b25ccd30..1140ffdb 100644 --- a/server/streamServer.cpp +++ b/server/streamServer.cpp @@ -44,7 +44,7 @@ void StreamServer::onStateChanged(const PcmStream* pcmStream, const ReaderState& // logO << pcmStream->toJson().dump(4); json notification = jsonrpcpp::Notification("Stream.OnUpdate", jsonrpcpp::Parameter("id", pcmStream->getId(), "stream", pcmStream->toJson())).to_json(); controlServer_->send(notification.dump(), NULL); - cout << "Notification:\n" << notification.dump(4) << "\n"; + cout << "Notification: " << notification.dump() << "\n"; } @@ -101,7 +101,7 @@ void StreamServer::onDisconnect(StreamSession* streamSession) { json notification = jsonrpcpp::Notification("Client.OnDisconnect", jsonrpcpp::Parameter("id", clientInfo->id, "client", clientInfo->toJson())).to_json(); controlServer_->send(notification.dump()); - cout << "Notification:\n" << notification.dump(4) << "\n"; + cout << "Notification: " << notification.dump() << "\n"; } } @@ -122,7 +122,7 @@ void StreamServer::ProcessRequest(const jsonrpcpp::request_ptr request, jsonrpcp if (request->method == "Client.GetStatus") { - result = clientInfo->toJson(); + result["client"] = clientInfo->toJson(); } else if (request->method == "Client.SetVolume") { @@ -184,7 +184,7 @@ void StreamServer::ProcessRequest(const jsonrpcpp::request_ptr request, jsonrpcp if (request->method == "Group.GetStatus") { - result = group->toJson(); + result["group"] = group->toJson(); } else if (request->method == "Group.SetMute") { @@ -313,7 +313,7 @@ void StreamServer::ProcessRequest(const jsonrpcpp::request_ptr request, jsonrpcp } else if (request->method == "Server.GetStatus") { - result = Config::instance().getServerStatus(streamManager_->toJson()); + result["server"] = Config::instance().getServerStatus(streamManager_->toJson()); } else if (request->method == "Server.DeleteClient") { @@ -499,13 +499,13 @@ void StreamServer::onMessageReceived(StreamSession* connection, const msg::BaseM json server = Config::instance().getServerStatus(streamManager_->toJson()); json notification = jsonrpcpp::Notification("Server.OnUpdate", jsonrpcpp::Parameter("server", server)).to_json(); controlServer_->send(notification.dump()); - cout << "Notification:\n" << notification.dump(4) << "\n"; + cout << "Notification: " << notification.dump() << "\n"; } else { json notification = jsonrpcpp::Notification("Client.OnConnect", jsonrpcpp::Parameter("id", client->id, "client", client->toJson())).to_json(); controlServer_->send(notification.dump()); - cout << "Notification:\n" << notification.dump(4) << "\n"; + cout << "Notification: " << notification.dump() << "\n"; } // cout << Config::instance().getServerStatus(streamManager_->toJson()).dump(4) << "\n"; // cout << group->toJson().dump(4) << "\n";