Skip to content

Commit

Permalink
Fixes coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
riban-bw committed Apr 1, 2024
1 parent 6573b9c commit 48f2d6b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 39 deletions.
4 changes: 1 addition & 3 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ class CClient : public QObject
Channel.GetBufErrorRates ( vecErrRates, dLimit, dMaxUpLimit );
}

CProtocol * getConnLessProtocol() {
return &ConnLessProtocol;
}
CProtocol * getConnLessProtocol() { return &ConnLessProtocol; }

// settings
CChannelCoreInfo ChannelInfo;
Expand Down
66 changes: 30 additions & 36 deletions src/clientrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,37 +101,36 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
/// @param {string} params.servers[*].name - Server name
/// @param {string} params.servers[*].country - Server country
/// @param {string} params.servers[*].city - Server city
connect ( pClient->getConnLessProtocol(), &CProtocol::CLServerListReceived, [=] ( CHostAddress /* unused */, CVector<CServerInfo> vecServerInfo ) {
QJsonArray arrServerInfo;
for ( const auto& serverInfo : vecServerInfo )
{
QJsonObject objServerInfo{
{ "address", serverInfo.HostAddr.toString() },
{ "name", serverInfo.strName },
{ "country", QLocale::countryToString ( serverInfo.eCountry) },
{ "city", serverInfo.strCity },
};
arrServerInfo.append ( objServerInfo );
pClient->CreateCLServerListPingMes ( serverInfo.HostAddr );
}
pRpcServer->BroadcastNotification ( "jamulusclient/serverListReceived",
QJsonObject{
{ "servers", arrServerInfo },
} );
} );
connect ( pClient->getConnLessProtocol(),
&CProtocol::CLServerListReceived,
[=] ( CHostAddress /* unused */, CVector<CServerInfo> vecServerInfo ) {
QJsonArray arrServerInfo;
for ( const auto& serverInfo : vecServerInfo )
{
QJsonObject objServerInfo{
{ "address", serverInfo.HostAddr.toString() },
{ "name", serverInfo.strName },
{ "country", QLocale::countryToString ( serverInfo.eCountry ) },
{ "city", serverInfo.strCity },
};
arrServerInfo.append ( objServerInfo );
pClient->CreateCLServerListPingMes ( serverInfo.HostAddr );
}
pRpcServer->BroadcastNotification ( "jamulusclient/serverListReceived",
QJsonObject{
{ "servers", arrServerInfo },
} );
} );

/// @rpc_notification jamulusclient/serverInfoReceived
/// @brief Emitted when a server info is received.
/// @param {string} params.address - The server socket address
/// @param {number} params.pingtime - The round-trip ping time in ms
/// @param {number} params.numClients - The quantity of clients connected to the server
connect (pClient, &CClient::CLPingTimeWithNumClientsReceived, [=] ( CHostAddress InetAddr, int iPingTime, int iNumClients ) {
pRpcServer->BroadcastNotification ( "jamulusclient/serverInfoReceived",
QJsonObject{
{"address", InetAddr.toString()},
{"pingTime", iPingTime},
{"numClients", iNumClients}
} );
connect ( pClient, &CClient::CLPingTimeWithNumClientsReceived, [=] ( CHostAddress InetAddr, int iPingTime, int iNumClients ) {
pRpcServer->BroadcastNotification (
"jamulusclient/serverInfoReceived",
QJsonObject{ { "address", InetAddr.toString() }, { "pingTime", iPingTime }, { "numClients", iNumClients } } );
} );

/// @rpc_notification jamulusclient/disconnected
Expand All @@ -143,10 +142,7 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
/// @brief Emitted when the client is connected to a server who's recorder state changes.
/// @param {number} params.state - The recorder state
connect ( pClient, &CClient::RecorderStateReceived, [=] ( const ERecorderState newRecorderState ) {
pRpcServer->BroadcastNotification ( "jamulusclient/recorderState",
QJsonObject{
{"state", newRecorderState}
} );
pRpcServer->BroadcastNotification ( "jamulusclient/recorderState", QJsonObject{ { "state", newRecorderState } } );
} );

/// @rpc_method jamulus/pollServerList
Expand All @@ -162,18 +158,16 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
}

CHostAddress haDirectoryAddress;
if ( NetworkUtil().ParseNetworkAddress (
jsonDirectoryIp.toString(),
haDirectoryAddress,
false ) )
if ( NetworkUtil().ParseNetworkAddress ( jsonDirectoryIp.toString(), haDirectoryAddress, false ) )
{
// send the request for the server list
pClient->CreateCLReqServerListMes( haDirectoryAddress );
pClient->CreateCLReqServerListMes ( haDirectoryAddress );
response["result"] = "ok";
}
else
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: directory is not a valid socket address" );
response["error"] =
CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: directory is not a valid socket address" );
}

response["result"] = "ok";
Expand All @@ -191,7 +185,7 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare
return;
}

if ( pClient->SetServerAddr(jsonAddr.toString()) )
if ( pClient->SetServerAddr( jsonAddr.toString() ) )
{
if ( !pClient->IsRunning() )
{
Expand Down

0 comments on commit 48f2d6b

Please sign in to comment.