@@ -53,8 +53,10 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
5353 // / @param {number} params.clients[*].id - The channel ID.
5454 // / @param {string} params.clients[*].name - The musician’s name.
5555 // / @param {string} params.clients[*].skillLevel - The musician’s skill level (beginner, intermediate, expert, or null).
56+ // / @param {number} params.clients[*].countryId - The musician’s country ID (see QLocale::Country).
5657 // / @param {string} params.clients[*].country - The musician’s country.
5758 // / @param {string} params.clients[*].city - The musician’s city.
59+ // / @param {number} params.clients[*].instrumentId - The musician’s instrument ID (see CInstPictures::GetTable).
5860 // / @param {string} params.clients[*].instrument - The musician’s instrument.
5961 connect ( pClient, &CClient::ConClientListMesReceived, [=] ( CVector<CChannelInfo> vecChanInfo ) {
6062 QJsonArray arrChanInfo;
@@ -64,8 +66,10 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
6466 { " id" , chanInfo.iChanID },
6567 { " name" , chanInfo.strName },
6668 { " skillLevel" , SerializeSkillLevel ( chanInfo.eSkillLevel ) },
69+ { " countryId" , chanInfo.eCountry },
6770 { " country" , QLocale::countryToString ( chanInfo.eCountry ) },
6871 { " city" , chanInfo.strCity },
72+ { " instrumentId" , chanInfo.iInstrument },
6973 { " instrument" , CInstPictures::GetName ( chanInfo.iInstrument ) },
7074 };
7175 arrChanInfo.append ( objChanInfo );
@@ -97,10 +101,11 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
97101 // / @rpc_notification jamulusclient/serverListReceived
98102 // / @brief Emitted when the server list is received.
99103 // / @param {array} params.servers - The server list.
100- // / @param {string} params.servers[*].address - Socket address (ip_address:port)
101- // / @param {string} params.servers[*].name - Server name
102- // / @param {string} params.servers[*].country - Server country
103- // / @param {string} params.servers[*].city - Server city
104+ // / @param {string} params.servers[*].address - Socket address (ip_address:port).
105+ // / @param {string} params.servers[*].name - Server name.
106+ // / @param {number} params.servers[*].countryId - Server country ID (see QLocale::Country).
107+ // / @param {string} params.servers[*].country - Server country.
108+ // / @param {string} params.servers[*].city - Server city.
104109 connect ( pClient->getConnLessProtocol (),
105110 &CProtocol::CLServerListReceived,
106111 [=] ( CHostAddress /* unused */ , CVector<CServerInfo> vecServerInfo ) {
@@ -110,6 +115,7 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
110115 QJsonObject objServerInfo{
111116 { " address" , serverInfo.HostAddr .toString () },
112117 { " name" , serverInfo.strName },
118+ { " countryId" , serverInfo.eCountry },
113119 { " country" , QLocale::countryToString ( serverInfo.eCountry ) },
114120 { " city" , serverInfo.strCity },
115121 };
@@ -124,9 +130,9 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
124130
125131 // / @rpc_notification jamulusclient/serverInfoReceived
126132 // / @brief Emitted when a server info is received.
127- // / @param {string} params.address - The server socket address
128- // / @param {number} params.pingtime - The round-trip ping time in ms
129- // / @param {number} params.numClients - The quantity of clients connected to the server
133+ // / @param {string} params.address - The server socket address.
134+ // / @param {number} params.pingtime - The round-trip ping time, in milliseconds.
135+ // / @param {number} params.numClients - The number of clients connected to the server.
130136 connect ( pClient, &CClient::CLPingTimeWithNumClientsReceived, [=] ( CHostAddress InetAddr, int iPingTime, int iNumClients ) {
131137 pRpcServer->BroadcastNotification (
132138 " jamulusclient/serverInfoReceived" ,
@@ -139,15 +145,15 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
139145 connect ( pClient, &CClient::Disconnected, [=]() { pRpcServer->BroadcastNotification ( " jamulusclient/disconnected" , QJsonObject{} ); } );
140146
141147 // / @rpc_notification jamulusclient/recorderState
142- // / @brief Emitted when the client is connected to a server who's recorder state changes.
143- // / @param {number} params.state - The recorder state
148+ // / @brief Emitted when the client is connected to a server whose recorder state changes.
149+ // / @param {number} params.state - The recorder state.
144150 connect ( pClient, &CClient::RecorderStateReceived, [=] ( const ERecorderState newRecorderState ) {
145151 pRpcServer->BroadcastNotification ( " jamulusclient/recorderState" , QJsonObject{ { " state" , newRecorderState } } );
146152 } );
147153
148- // / @rpc_method jamulus /pollServerList
149- // / @brief Request list of servers in a directory
150- // / @param {string} params.directory - socket address of directory to query, e.g. anygenre1.jamulus.io:22124.
154+ // / @rpc_method jamulusclient /pollServerList
155+ // / @brief Request list of servers in a directory.
156+ // / @param {string} params.directory - Socket address of directory to query. Example: anygenre1.jamulus.io:22124
151157 // / @result {string} result - "ok" or "error" if bad arguments.
152158 pRpcServer->HandleMethod ( " jamulusclient/pollServerList" , [=] ( const QJsonObject& params, QJsonObject& response ) {
153159 auto jsonDirectoryIp = params[" directory" ];
@@ -173,46 +179,6 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
173179 response[" result" ] = " ok" ;
174180 } );
175181
176- // / @rpc_method jamulusclient/connect
177- // / @brief Disconnect client from server
178- // / @param {string} params.address - Server socket address (ip_addr:port).
179- // / @result {string} result - Always "ok".
180- pRpcServer->HandleMethod ( " jamulusclient/connect" , [=] ( const QJsonObject& params, QJsonObject& response ) {
181- auto jsonAddr = params[" address" ];
182- if ( !jsonAddr.isString () )
183- {
184- response[" error" ] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, " Invalid params: address is not a string" );
185- return ;
186- }
187-
188- if ( pClient->SetServerAddr ( jsonAddr.toString () ) )
189- {
190- if ( !pClient->IsRunning () )
191- {
192- pClient->Start ();
193- }
194- response[" result" ] = " ok" ;
195- }
196- else
197- {
198- response[" error" ] = CRpcServer::CreateJsonRpcError ( 1 , " Bad server address" );
199- }
200- } );
201-
202- // / @rpc_method jamulusclient/disconnect
203- // / @brief Disconnect client from server
204- // / @param {object} params - No parameters (empty object).
205- // / @result {string} result - Always "ok".
206- pRpcServer->HandleMethod ( " jamulusclient/disconnect" , [=] ( const QJsonObject& params, QJsonObject& response ) {
207- if ( pClient->IsRunning () )
208- {
209- pClient->Stop ();
210- }
211-
212- response[" result" ] = " ok" ;
213- Q_UNUSED ( params );
214- } );
215-
216182 // / @rpc_method jamulus/getMode
217183 // / @brief Returns the current mode, i.e. whether Jamulus is running as a server or client.
218184 // / @param {object} params - No parameters (empty object).
@@ -239,16 +205,20 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
239205 // / @result {number} result.id - The channel ID.
240206 // / @result {string} result.name - The musician’s name.
241207 // / @result {string} result.skillLevel - The musician’s skill level (beginner, intermediate, expert, or null).
208+ // / @result {number} result.countryId - The musician’s country ID (see QLocale::Country).
242209 // / @result {string} result.country - The musician’s country.
243210 // / @result {string} result.city - The musician’s city.
244- // / @result {number} result.instrument - The musician’s instrument.
211+ // / @result {number} result.instrumentId - The musician’s instrument ID (see CInstPictures::GetTable).
212+ // / @result {string} result.instrument - The musician’s instrument.
245213 // / @result {string} result.skillLevel - Your skill level (beginner, intermediate, expert, or null).
246214 pRpcServer->HandleMethod ( " jamulusclient/getChannelInfo" , [=] ( const QJsonObject& params, QJsonObject& response ) {
247215 QJsonObject result{
248216 // TODO: We cannot include "id" here is pClient->ChannelInfo is a CChannelCoreInfo which lacks that field.
249217 { " name" , pClient->ChannelInfo .strName },
218+ { " countryId" , pClient->ChannelInfo .eCountry },
250219 { " country" , QLocale::countryToString ( pClient->ChannelInfo .eCountry ) },
251220 { " city" , pClient->ChannelInfo .strCity },
221+ { " instrumentId" , pClient->ChannelInfo .iInstrument },
252222 { " instrument" , CInstPictures::GetName ( pClient->ChannelInfo .iInstrument ) },
253223 { " skillLevel" , SerializeSkillLevel ( pClient->ChannelInfo .eSkillLevel ) },
254224 };
0 commit comments