Skip to content

Commit

Permalink
Merge pull request #2505 from Rob-NY/rpc_server_directory_name_2467
Browse files Browse the repository at this point in the history
JSON-RPC: Add server directory name (#2467)
  • Loading branch information
hoffie authored Mar 14, 2022
2 parents 1a3a72a + 5200702 commit d48c442
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/JSON-RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Parameters:

| Name | Type | Description |
| --- | --- | --- |
| params | object | No parameters (empty object). |
| params.secret | string | The preshared secret key. |

Results:

Expand Down Expand Up @@ -276,6 +276,7 @@ Results:
| result.city | string | The server city. |
| result.countryId | number | The server country ID (see QLocale::Country). |
| result.welcomeMessage | string | The server welcome message. |
| result.directoryServer | string | The directory server to which this server requested registration, or blank if none. |
| result.registrationStatus | string | The server registration status as string (see ESvrRegStatus and SerializeRegistrationStatus). |


Expand Down
2 changes: 1 addition & 1 deletion src/rpcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void CRpcServer::ProcessMessage ( QTcpSocket* pSocket, QJsonObject message, QJso
{
/// @rpc_method jamulus/apiAuth
/// @brief Authenticates the connection which is a requirement for calling further methods.
/// @param {object} params - No parameters (empty object).
/// @param {string} params.secret - The preshared secret key.
/// @result {string} result - "ok" on success
HandleApiAuth ( pSocket, params, response );
return;
Expand Down
7 changes: 7 additions & 0 deletions src/serverrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,20 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare
/// @result {string} result.city - The server city.
/// @result {number} result.countryId - The server country ID (see QLocale::Country).
/// @result {string} result.welcomeMessage - The server welcome message.
/// @result {string} result.directoryServer - The directory server to which this server requested registration, or blank if none.
/// @result {string} result.registrationStatus - The server registration status as string (see ESvrRegStatus and SerializeRegistrationStatus).
pRpcServer->HandleMethod ( "jamulusserver/getServerProfile", [=] ( const QJsonObject& params, QJsonObject& response ) {
QString dsName = "";

if ( AT_NONE != pServer->GetDirectoryType() )
dsName = NetworkUtil::GetDirectoryAddress ( pServer->GetDirectoryType(), pServer->GetDirectoryAddress() );

QJsonObject result{
{ "name", pServer->GetServerName() },
{ "city", pServer->GetServerCity() },
{ "countryId", pServer->GetServerCountry() },
{ "welcomeMessage", pServer->GetWelcomeMessage() },
{ "directoryServer", dsName },
{ "registrationStatus", SerializeRegistrationStatus ( pServer->GetSvrRegStatus() ) },
};
response["result"] = result;
Expand Down

0 comments on commit d48c442

Please sign in to comment.