-
Notifications
You must be signed in to change notification settings - Fork 242
Add new JSON-RPC API calls, with documentation #3660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,39 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe | |
| response["result"] = "ok"; | ||
| } ); | ||
|
|
||
| /// @rpc_method jamulusclient/getDirectories | ||
| /// @brief Returns the list of directories in the same order as presented in Jamulus. | ||
| /// @param {object} params - No parameters (empty object). | ||
| /// @result {array} result - Array of directory socket address strings, usable as params.directory in jamulusclient/pollServerList. | ||
| pRpcServer->HandleMethod ( "jamulusclient/getDirectories", [=] ( const QJsonObject& params, QJsonObject& response ) { | ||
| QJsonArray arrDirectories; | ||
| // built-in directories in UI order | ||
| for ( int i = AT_DEFAULT; i < AT_CUSTOM; i++ ) | ||
| { | ||
| arrDirectories.append ( NetworkUtil::GetDirectoryAddress ( static_cast<EDirectoryType> ( i ), "" ) ); | ||
| } | ||
| // custom directories — stored newest-first, displayed oldest-first (reverse iteration) | ||
| for ( int i = MAX_NUM_SERVER_ADDR_ITEMS - 1; i >= 0; i-- ) | ||
| { | ||
| if ( !m_pSettings->vstrDirectoryAddress[i].isEmpty() ) | ||
| { | ||
| arrDirectories.append ( m_pSettings->vstrDirectoryAddress[i] ); | ||
| } | ||
| } | ||
| response["result"] = arrDirectories; | ||
| Q_UNUSED ( params ); | ||
| } ); | ||
|
|
||
| /// @rpc_method jamulusclient/getCurrentDirectory | ||
| /// @brief Returns the currently selected directory socket address. | ||
| /// @param {object} params - No parameters (empty object). | ||
| /// @result {string} result - The socket address of the current directory, usable as params.directory in jamulusclient/pollServerList. | ||
| pRpcServer->HandleMethod ( "jamulusclient/getCurrentDirectory", [=] ( const QJsonObject& params, QJsonObject& response ) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Go to Settings -> Advanced. The data item you're collecting here is the "current" entry in the custom directories list, I think. Not Connect->Directory.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So again, ideally:
I think there are JSON-RPC calls that can handle emitted signals by emitting new state, aren't there? They not just responses?
This also begs for a JSON-RPC "setCurrentDirectory", of course, to act the same as selecting a new entry in the dropdown. |
||
| response["result"] = | ||
| NetworkUtil::GetDirectoryAddress ( m_pSettings->eDirectoryType, m_pSettings->vstrDirectoryAddress[m_pSettings->iCustomDirectoryIndex] ); | ||
| Q_UNUSED ( params ); | ||
| } ); | ||
|
|
||
| /// @rpc_method jamulus/getMode | ||
| /// @brief Returns the current mode, i.e. whether Jamulus is running as a server or client. | ||
| /// @param {object} params - No parameters (empty object). | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would be simplified:
Otherwise we're duplicating functionality for no benefit.