small RPC API change

This commit is contained in:
badaix 2017-02-25 10:46:23 +01:00
parent 9e314056b6
commit 0b69bf2ff3
2 changed files with 12 additions and 12 deletions

View file

@ -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

View file

@ -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";