Skip to content
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

Add JSON-RPC access to directories and server lists (without connect/disconnect methods) #3479

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ann0see
Copy link
Member

@ann0see ann0see commented Feb 13, 2025

Short description of changes

Modified version of: #3249

  • Removed disconnect and connect methods since calling them would break the UI
  • Rebased to main

Quoting the initial PR:

Adds JSON-RPC notification of server lists from directories. Allows polling a directory for this info.

CHANGELOG: Added jamulusclient/pollServerList methods and jamulusclient/receivedServerList notification to JSON-RPC interface.

Context: Fixes an issue?

As discussed here, it may be advantageous to increase the control and monitoring provided by the JSON-RPC interface. This provides access to server lists on directories.

Does this change need documentation? What needs to be documented and how?

This PR adds the associated documentation of the new method and notification in the JSON-RPC md page.

Status of this Pull Request

To be tested.

What is missing until this pull request can be merged?

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

Squash from: jamulussoftware#3249

rpc_notification jamulusclient/serverListReceived
rpc_method jamulus/pollServerList

Change JSON-RPC for server list.

Use pollServerList instead of getServerList. (No result returned from the call.)
Change "address" to "url"

Adds documentation for new JSON-RPC methods

Consistent use of countryId

Fixes JSON-RPC docs

JSON-RPC fixes for feedback to PR

Changes method "jamulus/pollServerList" to "jamulusclient/pollServerList" (for consistency).
Changes "url" to "address" in protocol and "server address" in docs.
Fixes typo in countryId.

JSON-RPC Enhancements

Adds jamulusclient/connect method.
Adds jamulusclient/disconnect method.
Adds jamulusclient/serverInfoReceived notification.
Return country string rather than (QT specific) country code.
Request server info after server list received (to get each server's ping time and num clients).

JSON-RPC enhancements

Adds method jamulusclient/recorderState.
Changes intrument code to instrument name (remote client may not have access to lookup table).
Fixes errors in docs.

Fixes coding style

Update docs

Fix coding style
@ann0see ann0see force-pushed the jsonrpc/addDirectoryMethods branch from d830548 to 324c588 Compare February 13, 2025 10:26
@ann0see ann0see added this to the Release 3.12.0 milestone Feb 13, 2025
These methods unfortunately break the GUI if called
@ann0see ann0see force-pushed the jsonrpc/addDirectoryMethods branch from 324c588 to 3c89fe5 Compare February 13, 2025 10:28
@ann0see ann0see requested review from pljones and softins February 13, 2025 10:30
@ann0see
Copy link
Member Author

ann0see commented Feb 13, 2025

I'd like to process with the content of #3249 without the disconnect and connect methods.
Second review will follow.

@riban-bw since you wrote the initial code, I'd also like to hear your opinion once reviews happen here.

Copy link
Member

@softins softins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a number of suggestions.

Co-authored-by: Tony Mountifield <[email protected]>
docs/JSON-RPC.md Outdated
@@ -129,6 +129,23 @@ Results:
| result.version | string | The Jamulus version. |


### jamulus/pollServerList

Request list of servers in a directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Request list of servers in a directory
Request list of servers in a directory.

@@ -129,6 +129,23 @@ Results:
| result.version | string | The Jamulus version. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency on a page is a mercy for readers, and this page consistently puts a period behind non-sentences. Ideally, none would include a period.

docs/JSON-RPC.md Outdated

| Name | Type | Description |
| --- | --- | --- |
| params.directory | string | socket address of directory to query, e.g. anygenre1.jamulus.io:22124. |
Copy link
Contributor

@mcfnord mcfnord Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.directory | string | socket address of directory to query, e.g. anygenre1.jamulus.io:22124. |
| params.directory | string | Socket address of directory to query. Example: anygenre1.jamulus.io:22124. |

e.g. is not used elsewhere on this page. Perhaps it could be avoided here.

docs/JSON-RPC.md Outdated

| Name | Type | Description |
| --- | --- | --- |
| params.state | number | The recorder state |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.state | number | The recorder state |
| params.state | number | The recorder state. |

I hate this fix, but it's consistent with the rest of the page.

docs/JSON-RPC.md Outdated

| Name | Type | Description |
| --- | --- | --- |
| params.address | string | The server socket address |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.address | string | The server socket address |
| params.address | string | The server socket address. |

docs/JSON-RPC.md Outdated
| Name | Type | Description |
| --- | --- | --- |
| params.address | string | The server socket address |
| params.pingtime | number | The round-trip ping time in ms |
Copy link
Contributor

@mcfnord mcfnord Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.pingtime | number | The round-trip ping time in ms |
| params.pingtime | number | The round-trip ping time, in milliseconds. |

docs/JSON-RPC.md Outdated
| --- | --- | --- |
| params.address | string | The server socket address |
| params.pingtime | number | The round-trip ping time in ms |
| params.numClients | number | The quantity of clients connected to the server |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.numClients | number | The quantity of clients connected to the server |
| params.numClients | number | The number of clients connected to the server. |

Perhaps there's a notion that the definition of something shouldn't use the same word. Maybe. But the only existing similar usage on this page is result.clients[*].channels, and it says number rather than quantity.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And the aim is to contextualise "number of clients" rather than explain "number", "of" or "clients".)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry! I tend to use the word, "quantity" in docs to avoid ambiguity. Feel free to use the language with which you feel most comfortable.

docs/JSON-RPC.md Outdated
| Name | Type | Description |
| --- | --- | --- |
| params.servers | array | The server list. |
| params.servers[*].address | string | Socket address (ip_address:port) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.servers[*].address | string | Socket address (ip_address:port) |
| params.servers[*].address | string | Socket address (ip_address:port). |

docs/JSON-RPC.md Outdated
| --- | --- | --- |
| params.servers | array | The server list. |
| params.servers[*].address | string | Socket address (ip_address:port) |
| params.servers[*].name | string | Server name |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.servers[*].name | string | Server name |
| params.servers[*].name | string | Server name. |

docs/JSON-RPC.md Outdated
| params.servers[*].address | string | Socket address (ip_address:port) |
| params.servers[*].name | string | Server name |
| params.servers[*].countryId | number | Server country ID (see QLocale::Country). |
| params.servers[*].country | string | Server country |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| params.servers[*].country | string | Server country |
| params.servers[*].country | string | Server country. |

Copy link
Member Author

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcfnord applied. Thanks. I agree the "." change looks strange.

@ann0see ann0see requested a review from mcfnord February 28, 2025 20:16
@@ -286,6 +286,8 @@ class CClient : public QObject
Channel.GetBufErrorRates ( vecErrRates, dLimit, dMaxUpLimit );
}

CProtocol* getConnLessProtocol() { return &ConnLessProtocol; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. pClient gets passed to ClientRpc, which isn't a problem for threading. That should make calls to pClient->anything() thread-safe, right?

I'd just be more comfortable not to dig around inside pClient to the internals -- if pClient should expose a change, it should have its own slot exposing that and signal it itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting on Team
Development

Successfully merging this pull request may close these issues.

5 participants