diff --git a/server/control_session_http.cpp b/server/control_session_http.cpp index e5318e02..ec111f46 100644 --- a/server/control_session_http.cpp +++ b/server/control_session_http.cpp @@ -220,16 +220,16 @@ void ControlSessionHttp::handle_request(http::requestonMessageReceived(shared_from_this(), std::string(req.body()), - [req = std::move(req), send = std::move(send)](const std::string& response) { - http::response res{http::status::ok, req.version()}; - res.set(http::field::server, HTTP_SERVER_NAME); - res.set(http::field::content_type, "application/json"); - res.keep_alive(req.keep_alive()); - res.body() = response; - res.prepare_payload(); - return send(std::move(res)); - }); + std::string request = req.body(); + return message_receiver_->onMessageReceived(shared_from_this(), request, [req = std::move(req), send = std::move(send)](const std::string& response) { + http::response res{http::status::ok, req.version()}; + res.set(http::field::server, HTTP_SERVER_NAME); + res.set(http::field::content_type, "application/json"); + res.keep_alive(req.keep_alive()); + res.body() = response; + res.prepare_payload(); + return send(std::move(res)); + }); } // Request path must be absolute and not contain "..". diff --git a/server/server.cpp b/server/server.cpp index b1e5879d..1be53ba6 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -483,14 +483,14 @@ void Server::processRequest(const jsonrpcpp::request_ptr request, const OnRespon if (stream == nullptr) throw jsonrpcpp::InternalErrorException("Stream not found", request->id()); - 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"; + stream->setProperty(*request, [request, on_response](const jsonrpcpp::Response& props_response) { + LOG(INFO, LOG_TAG) << "Received response for Stream.SetProperty, id: " << props_response.id() << ", result: " << props_response.result() + << ", error: " << props_response.error().code() << "\n"; + auto response = make_shared(request->id(), props_response.result()); + on_response(response, nullptr); }); - // Setup response - // TODO: error handling - result["id"] = streamId; + return; } else if (request->method() == "Stream.AddStream") { diff --git a/server/streamreader/pcm_stream.cpp b/server/streamreader/pcm_stream.cpp index 483f7501..b60e5b1c 100644 --- a/server/streamreader/pcm_stream.cpp +++ b/server/streamreader/pcm_stream.cpp @@ -492,7 +492,6 @@ void PcmStream::setProperty(const jsonrpcpp::Request& request, const CtrlScript: void PcmStream::control(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler) { - std::string command = request.params().get("command"); static std::set supported_commands{"Next", "Previous", "Pause", "PlayPause", "Stop", "Play", "Seek", "SetPosition"}; if ((supported_commands.find(command) == supported_commands.end()) ||