mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-07 03:37:42 +02:00
Add reponse handlers for requests
This commit is contained in:
parent
d32378bd2e
commit
5c28809b43
3 changed files with 170 additions and 115 deletions
|
@ -457,8 +457,10 @@ void Server::processRequest(const jsonrpcpp::request_ptr request, jsonrpcpp::ent
|
|||
if (stream == nullptr)
|
||||
throw jsonrpcpp::InternalErrorException("Stream not found", request->id());
|
||||
|
||||
// Set metadata from request
|
||||
stream->control(request->params().get("command"), request->params().has("params") ? request->params().get("params") : json{});
|
||||
stream->control(*request, [](const jsonrpcpp::Response& response) {
|
||||
LOG(INFO, LOG_TAG) << "Received response for Stream.Control, id: " << response.id() << ", result: " << response.result()
|
||||
<< ", error: " << response.error().code() << "\n";
|
||||
});
|
||||
|
||||
// Setup response
|
||||
result["id"] = streamId;
|
||||
|
@ -477,7 +479,10 @@ void Server::processRequest(const jsonrpcpp::request_ptr request, jsonrpcpp::ent
|
|||
if (stream == nullptr)
|
||||
throw jsonrpcpp::InternalErrorException("Stream not found", request->id());
|
||||
|
||||
stream->setProperty(request->params().get("property"), request->params().get("value"));
|
||||
stream->setProperty(*request, [](const jsonrpcpp::Response& response) {
|
||||
LOG(INFO, LOG_TAG) << "Received response for Stream.SetProperty, id: " << response.id() << ", result: " << response.result()
|
||||
<< ", error: " << response.error().code() << "\n";
|
||||
});
|
||||
|
||||
// Setup response
|
||||
// TODO: error handling
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue