Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/JSON-RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ Results:
| result | string | Always "ok". |


### jamulusclient/setInstrumentCode

Sets your instrument code.

Parameters:

| Name | Type | Description |
| --- | --- | --- |
| params.instrCode | number | The new instrument code. |

Results:

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


### jamulusclient/setMidiSettings

Sets one or more MIDI controller settings.
Expand Down
26 changes: 26 additions & 0 deletions src/clientrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,32 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe
response["result"] = "ok";
} );

/// @rpc_method jamulusclient/setInstrumentCode
/// @brief Sets your instrument code.
/// @param {number} params.instrCode - The new instrument code.
/// @result {string} result - Always "ok".
pRpcServer->HandleMethod ( "jamulusclient/setInstrumentCode", [=] ( const QJsonObject& params, QJsonObject& response ) {
auto jsonInstrCode = params["instrCode"];

if ( !jsonInstrCode.isDouble() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: instrCode is not a number" );
return;
}

const int _iInstrument = jsonInstrCode.toInt();

if ( CInstPictures::GetName ( _iInstrument ).isEmpty() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: unknown instrCode" );
return;
}

pClient->ChannelInfo.iInstrument = _iInstrument;
pClient->SetRemoteInfo();
response["result"] = "ok";
} );

/// @rpc_method jamulusclient/sendChatText
/// @brief Sends a chat text message.
/// @param {string} params.chatText - The chat text message.
Expand Down
Loading