Skip to content
18 changes: 18 additions & 0 deletions docs/JSON-RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,24 @@ Results:
| result | string | Always "ok". |


### jamulusclient/setFaderLevel

Sets the fader level. Example: {"id":1,"jsonrpc":"2.0","method":"jamulusclient/setFaderLevel","params":{"channelIndex": 0,"level": 50}}.

Parameters:

| Name | Type | Description |
| --- | --- | --- |
| params.channelIndex | number | The channel index of the fader to be set. |
| params.level | number | The fader level in range 0..100. |

Results:

| Name | Type | Description |
| --- | --- | --- |
| result | string | Always "ok". |


### jamulusclient/setName

Sets your name.
Expand Down
2 changes: 2 additions & 0 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ class CClient : public QObject
void OnTimerRemoteChanGainOrPan();
void StartTimerGainOrPan();

void SetControllerInFaderLevel ( int iChannelIdx, int iValue ) { OnControllerInFaderLevel ( iChannelIdx, iValue ); }

void SetInputBoost ( const int iNewBoost ) { iInputBoost = iNewBoost; }

void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); }
Expand Down
27 changes: 27 additions & 0 deletions src/clientrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,33 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare

response["result"] = "ok";
} );

/// @rpc_method jamulusclient/setFaderLevel
/// @brief Sets the fader level. Example: {"id":1,"jsonrpc":"2.0","method":"jamulusclient/setFaderLevel","params":{"channelIndex": 0,"level":
/// 50}}.
/// @param {number} params.channelIndex - The channel index of the fader to be set.
/// @param {number} params.level - The fader level in range 0..100.
/// @result {string} result - Always "ok".
pRpcServer->HandleMethod ( "jamulusclient/setFaderLevel", [=] ( const QJsonObject& params, QJsonObject& response ) {
auto jsonChannelIndex = params["channelIndex"];
if ( !jsonChannelIndex.isDouble() || ( jsonChannelIndex.toInt() < 0 ) || ( jsonChannelIndex.toInt() > MAX_NUM_CHANNELS ) )
{
response["error"] =
CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: channelIndex is not a number or out-of-range" );
return;
}

auto jsonLevel = params["level"];
if ( !jsonLevel.isDouble() || ( jsonLevel.toInt() < 0 ) || ( jsonLevel.toInt() > 100 ) )
{
response["error"] =
CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: level is not a number or out-of-range" );
return;
}

pClient->SetControllerInFaderLevel ( jsonChannelIndex.toInt(), jsonLevel.toInt() );
response["result"] = "ok";
} );
}

QJsonValue CClientRpc::SerializeSkillLevel ( ESkillLevel eSkillLevel )
Expand Down
Loading