Skip to content

Commit

Permalink
JSON-RPC fixes for feedback to PR
Browse files Browse the repository at this point in the history
Changes method "jamulus/pollServerList" to "jamulusclient/pollServerList" (for consistency).
Changes "url" to "address" in protocol and "server address" in docs.
Fixes typo in countryId.
  • Loading branch information
riban-bw committed Mar 23, 2024
1 parent cbeb68e commit 86ed64e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/JSON-RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,19 @@ Results:

### jamulusclient/pollServerList

Requests server list.
Requests the server list from a specified directory.

Parameters:

| Name | Type | Description |
| --- | --- | --- |
| params.directory | string | URL of directory, e.g. anygenre1.jamulus.io:22124 |
| params.directory | string | Socket address of directory, e.g. anygenre1.jamulus.io:22124 |

Results:

| Name | Type | Description |
| --- | --- | --- |
| result | string | "ok" or "error" if invalid URL |
| result | string | "ok" or "error" if invalid socket address |

### jamulusclient/sendChatText

Expand Down Expand Up @@ -474,7 +474,7 @@ Parameters:
| Name | Type | Description |
| --- | --- | --- |
| params.servers | array | The server list. |
| params.servers[*].url | url | The server's URL. |
| params.servers[*].address | string | The server's socket address. |
| params.servers[*].name | string | The server’s name. |
| params.servers[*].countryId | number | The servers’s country ID (see QLocale::Country). |
| params.servers[*].city | string | The server’s city. |
Expand Down
12 changes: 6 additions & 6 deletions src/clientrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
/// @rpc_notification jamulusclient/serverListReceived
/// @brief Emitted when the server list is received.
/// @param {array} params.servers - The server list.
/// @param {string} params.servers[*].url - IP Address
/// @param {string} params.servers[*].address - Socket address (ip_address:port)
/// @param {string} params.servers[*].name - Server name
/// @param {number} params.servers[*].countryId - Server country code
/// @param {string} params.servers[*].city - Server city
Expand All @@ -106,9 +106,9 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
for ( const auto& serverInfo : vecServerInfo )
{
QJsonObject objServerInfo{
{ "url", serverInfo.HostAddr.toString() },
{ "address", serverInfo.HostAddr.toString() },
{ "name", serverInfo.strName },
{ "countryI", serverInfo.eCountry },
{ "countryId", serverInfo.eCountry },
{ "city", serverInfo.strCity },
};
arrServerInfo.append ( objServerInfo );
Expand All @@ -126,9 +126,9 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare

/// @rpc_method jamulus/pollServerList
/// @brief Request list of servers in a directory
/// @param {string} params.directory - URL of directory to query, e.g. anygenre1.jamulus.io:22124.
/// @param {string} params.directory - socket address of directory to query, e.g. anygenre1.jamulus.io:22124.
/// @result {string} result - "ok" or "error" if bad arguments.
pRpcServer->HandleMethod ( "jamulus/pollServerList", [=] ( const QJsonObject& params, QJsonObject& response ) {
pRpcServer->HandleMethod ( "jamulusclient/pollServerList", [=] ( const QJsonObject& params, QJsonObject& response ) {
auto jsonDirectoryIp = params["directory"];
if ( !jsonDirectoryIp.isString() )
{
Expand All @@ -148,7 +148,7 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
}
else
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: directory is not a valid url" );
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: directory is not a valid socket address" );
}

response["result"] = "ok";
Expand Down

0 comments on commit 86ed64e

Please sign in to comment.