Skip to content

Commit 5c23d52

Browse files
authored
Add fader level set method to RPC remote interface (#3571)
* add RPC method setFaderLevel (not yet working) * introduce function SetControllerInFaderLevel to be able to use controller in for RPC interface * add example for jamulusclient/setFaderLevel * add range check to RPC to be able to correctly inform the RPC user that the command he has send has a problem * clean up (TODO is already solved) * update RPC documentation * fix clang-format issues * fix check-json-rpc-docs * avoid renaming of existing function implementation * fix clang format issue --------- Co-authored-by: Volker Fischer <corrados@users.noreply.github.com>
1 parent 6c89081 commit 5c23d52

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

docs/JSON-RPC.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,24 @@ Results:
222222
| result | string | Always "ok". |
223223

224224

225+
### jamulusclient/setFaderLevel
226+
227+
Sets the fader level. Example: {"id":1,"jsonrpc":"2.0","method":"jamulusclient/setFaderLevel","params":{"channelIndex": 0,"level": 50}}.
228+
229+
Parameters:
230+
231+
| Name | Type | Description |
232+
| --- | --- | --- |
233+
| params.channelIndex | number | The channel index of the fader to be set. |
234+
| params.level | number | The fader level in range 0..100. |
235+
236+
Results:
237+
238+
| Name | Type | Description |
239+
| --- | --- | --- |
240+
| result | string | Always "ok". |
241+
242+
225243
### jamulusclient/setName
226244

227245
Sets your name.

src/client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ class CClient : public QObject
260260
void OnTimerRemoteChanGainOrPan();
261261
void StartTimerGainOrPan();
262262

263+
void SetControllerInFaderLevel ( int iChannelIdx, int iValue ) { OnControllerInFaderLevel ( iChannelIdx, iValue ); }
264+
263265
void SetInputBoost ( const int iNewBoost ) { iInputBoost = iNewBoost; }
264266

265267
void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); }

src/clientrpc.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,33 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
326326

327327
response["result"] = "ok";
328328
} );
329+
330+
/// @rpc_method jamulusclient/setFaderLevel
331+
/// @brief Sets the fader level. Example: {"id":1,"jsonrpc":"2.0","method":"jamulusclient/setFaderLevel","params":{"channelIndex": 0,"level":
332+
/// 50}}.
333+
/// @param {number} params.channelIndex - The channel index of the fader to be set.
334+
/// @param {number} params.level - The fader level in range 0..100.
335+
/// @result {string} result - Always "ok".
336+
pRpcServer->HandleMethod ( "jamulusclient/setFaderLevel", [=] ( const QJsonObject& params, QJsonObject& response ) {
337+
auto jsonChannelIndex = params["channelIndex"];
338+
if ( !jsonChannelIndex.isDouble() || ( jsonChannelIndex.toInt() < 0 ) || ( jsonChannelIndex.toInt() > MAX_NUM_CHANNELS ) )
339+
{
340+
response["error"] =
341+
CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: channelIndex is not a number or out-of-range" );
342+
return;
343+
}
344+
345+
auto jsonLevel = params["level"];
346+
if ( !jsonLevel.isDouble() || ( jsonLevel.toInt() < 0 ) || ( jsonLevel.toInt() > 100 ) )
347+
{
348+
response["error"] =
349+
CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: level is not a number or out-of-range" );
350+
return;
351+
}
352+
353+
pClient->SetControllerInFaderLevel ( jsonChannelIndex.toInt(), jsonLevel.toInt() );
354+
response["result"] = "ok";
355+
} );
329356
}
330357

331358
QJsonValue CClientRpc::SerializeSkillLevel ( ESkillLevel eSkillLevel )

0 commit comments

Comments
 (0)