diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index e9111187f4..e2eb457665 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -274,6 +274,23 @@ Results: | result | string | Always "ok". | +### jamulusclient/setInputBoost + +Sets the input boost factor. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.boost | int | boost factor, 1 (no boost) to 10. | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result | string | Always "ok". | + + ### jamulusclient/setMidiSettings Sets one or more MIDI controller settings. diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index 1f6671ca9e..15c17f3372 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -511,6 +511,30 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe response["result"] = "ok"; } ); + + /// @rpc_method jamulusclient/setInputBoost + /// @brief Sets the input boost factor. + /// @param {int} params.boost - boost factor, 1 (no boost) to 10. + /// @result {string} result - Always "ok". + pRpcServer->HandleMethod ( "jamulusclient/setInputBoost", [=] ( const QJsonObject& params, QJsonObject& response ) { + auto boost = params["boost"]; + if ( !boost.isDouble() ) + { + response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: boost is not a number" ); + return; + } + + const int iBoost = boost.toInt(); + if ( iBoost < 1 || iBoost > 10 ) + { + response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: boost must be between 1 and 10" ); + return; + } + + pClient->SetInputBoost ( iBoost ); + + response["result"] = "ok"; + } ); } QJsonValue CClientRpc::SerializeSkillLevel ( ESkillLevel eSkillLevel )