From ccfd268eef024862c56ac999650fa4aa667485ca Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Wed, 13 May 2026 14:53:58 +0200 Subject: [PATCH 1/6] add rpc methods - jamulus/getAvailableMethods - jamulusclient/setMuted - jamulusserver/broadcastChatMessage - jamulusserver/chatMessageReceived - jamulusserver/clientConnected - jamulusserver/clientDisconnected --- docs/JSON-RPC.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++ src/client.h | 1 + src/clientrpc.cpp | 17 ++++++++++ src/rpcserver.cpp | 26 ++++++++++++++ src/rpcserver.h | 7 ++-- src/server.cpp | 20 +++++++++++ src/server.h | 5 +++ src/serverrpc.cpp | 55 ++++++++++++++++++++++++++++++ 8 files changed, 214 insertions(+), 3 deletions(-) diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index cfe8dfbe3e..6f9abcc011 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -95,6 +95,23 @@ Results: | result | string | "ok" on success | +### jamulus/getAvailableMethods + +Returns all available rpc methods. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params | object | No parameters (empty object). | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result.methods | array | All available methods. | + + ### jamulus/getMode Returns the current mode, i.e. whether Jamulus is running as a server or client. @@ -291,6 +308,23 @@ Results: | result | string | Always "ok". | +### jamulusclient/setMuted + +Mutes or unmutes the client. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.muted | boolean | muted (true or false). | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result | string | Always "ok". | + + ### jamulusclient/setName Sets your name. @@ -325,6 +359,23 @@ Results: | result | string | Always "ok". | +### jamulusserver/broadcastChatMessage + +Sends a chat message to all connected clients. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.chatMessage | string | The chat message text. | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result | string | Always "ok". | + + ### jamulusserver/getClients Returns the list of connected clients along with details about them. @@ -621,3 +672,38 @@ Parameters: | params.servers[*].city | string | Server city. | +### jamulusserver/chatMessageReceived + +Emitted when a chat message is received. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.chatMessage | string | Chat message text. | + + +### jamulusserver/clientConnected + +Emitted when a client has connected to the server. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.id | number | The channel ID assigned to the client. | +| params.address | string | The client's address. | +| params.totalChannels | number | Number of total channels connected to the server. | + + +### jamulusserver/clientDisconnected + +Emitted when a client has disconnected from the server. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.id | number | The channel ID assigned to the client. | + + diff --git a/src/client.h b/src/client.h index 27c78cdf3d..b3a160be5b 100644 --- a/src/client.h +++ b/src/client.h @@ -329,6 +329,7 @@ class CClient : public QObject // settings CChannelCoreInfo ChannelInfo; QString strClientName; + void OnRPCInMuteMyself ( bool bMute ) { OnControllerInMuteMyself ( bMute ); } public: void SetSettings ( CClientSettings* settings ); diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index 02324121e3..9ba7060a1d 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -497,6 +497,23 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe response["result"] = jsonDevices; Q_UNUSED ( params ); } ); + + /// @rpc_method jamulusclient/setMuted + /// @brief Mutes or unmutes the client. + /// @param {boolean} params.muted - muted (true or false). + /// @result {string} result - Always "ok". + pRpcServer->HandleMethod ( "jamulusclient/setMuted", [=] ( const QJsonObject& params, QJsonObject& response ) { + auto muted = params["muted"]; + if ( !muted.isBool() ) + { + response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: muted is not a boolean" ); + return; + } + + pClient->OnRPCInMuteMyself ( muted.toBool() ); + + response["result"] = "ok"; + } ); } QJsonValue CClientRpc::SerializeSkillLevel ( ESkillLevel eSkillLevel ) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 2c05c2f12d..3ff0192454 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -66,6 +66,16 @@ CRpcServer::CRpcServer ( QObject* parent, QString strBindIP, int iPort, QString response["result"] = result; Q_UNUSED ( params ); } ); + + /// @rpc_method jamulus/getAvailableMethods + /// @brief Returns all available rpc methods. + /// @param {object} params - No parameters (empty object). + /// @result {array} result.methods - All available methods. + HandleMethod ( "jamulus/getAvailableMethods", [=] ( const QJsonObject& params, QJsonObject& response ) { + QJsonObject result = getAvailableMethods(); + response["result"] = result; + Q_UNUSED ( params ); + } ); } CRpcServer::~CRpcServer() @@ -224,6 +234,22 @@ void CRpcServer::HandleApiAuth ( QTcpSocket* pSocket, const QJsonObject& params, void CRpcServer::HandleMethod ( const QString& strMethod, CRpcHandler pHandler ) { mapMethodHandlers[strMethod] = pHandler; } +QJsonObject CRpcServer::getAvailableMethods() +{ + QJsonArray methods; + QMapIterator i ( mapMethodHandlers ); + + while ( i.hasNext() ) + { + i.next(); + methods.append ( i.key() ); + } + QJsonObject result{ + { "methods", methods }, + }; + return result; +} + void CRpcServer::ProcessMessage ( QTcpSocket* pSocket, QJsonObject message, QJsonObject& response ) { if ( !message["method"].isString() ) diff --git a/src/rpcserver.h b/src/rpcserver.h index cf9da2706f..8e3fbff342 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -69,9 +69,10 @@ class CRpcServer : public QObject CRpcServer ( QObject* parent, QString strBindIP, int iPort, QString secret ); virtual ~CRpcServer(); - bool Start(); - void HandleMethod ( const QString& strMethod, CRpcHandler pHandler ); - void BroadcastNotification ( const QString& strMethod, const QJsonObject& aParams ); + bool Start(); + void HandleMethod ( const QString& strMethod, CRpcHandler pHandler ); + void BroadcastNotification ( const QString& strMethod, const QJsonObject& aParams ); + QJsonObject getAvailableMethods(); static QJsonObject CreateJsonRpcError ( int code, QString message ); diff --git a/src/server.cpp b/src/server.cpp index 67274965bc..b17563fece 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -470,6 +470,8 @@ void CServer::OnNewConnection ( int iChID, int iTotChans, CHostAddress RecHostAd // logging of new connected channel Logging.AddNewConnection ( RecHostAddr.InetAddr, iTotChans ); + + emit ClientConnected ( iChID, RecHostAddr.InetAddr, iTotChans ); } void CServer::OnServerFull ( CHostAddress RecHostAddr ) @@ -876,6 +878,8 @@ void CServer::DecodeReceiveData ( const int iChanCnt, const int iNumClients ) { emit ClientDisconnected ( iCurChanID ); // TODO do this outside the mutex lock? } + // notify RPC server of disconnection + emit ClientDisconnectedRPC ( iCurChanID ); FreeChannel ( iCurChanID ); // note that the channel is now not in use @@ -1306,6 +1310,22 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, con vecChannels[i].CreateChatTextMes ( strActualMessageText ); } } + emit receivedChatMessage ( strActualMessageText ); +} + +// external chat +void CServer::CreateAndSendChatTextForAllConChannels ( const QString& strChatText ) +{ + // Send chat text to all connected clients --------------------------------- + for ( int i = 0; i < iMaxNumChannels; i++ ) + { + if ( vecChannels[i].IsConnected() ) + { + // send message + vecChannels[i].CreateChatTextMes ( strChatText ); + } + } + emit receivedChatMessage ( strChatText ); } void CServer::CreateAndSendRecorderStateForAllConChannels() diff --git a/src/server.h b/src/server.h index 2e6b13e835..e077d6026f 100644 --- a/src/server.h +++ b/src/server.h @@ -191,6 +191,8 @@ class CServer : public QObject, public CServerSlots void SetEnableDelayPanning ( bool bDelayPanningOn ) { bDelayPan = bDelayPanningOn; } bool IsDelayPanningEnabled() { return bDelayPan; } + virtual void CreateAndSendChatTextForAllConChannels ( const QString& strChatText ); + protected: // access functions for actual channels bool IsConnected ( const int iChanNum ) { return vecChannels[iChanNum].IsConnected(); } @@ -328,6 +330,9 @@ class CServer : public QObject, public CServerSlots void Started(); void Stopped(); void ClientDisconnected ( const int iChID ); + void ClientDisconnectedRPC ( const int iChID ); + void ClientConnected ( const int iChID, const QHostAddress RecHostAddr, const int iTotChans ); + void receivedChatMessage ( const QString& strChatText ); void SvrRegStatusChanged(); void AudioFrame ( const int iChID, const QString stChName, diff --git a/src/serverrpc.cpp b/src/serverrpc.cpp index 315a3e262c..491f641f40 100644 --- a/src/serverrpc.cpp +++ b/src/serverrpc.cpp @@ -56,6 +56,61 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare Q_UNUSED ( params ); } ); + /// @rpc_notification jamulusserver/clientConnected + /// @brief Emitted when a client has connected to the server. + /// @param {number} params.id - The channel ID assigned to the client. + /// @param {string} params.address - The client's address. + /// @param {number} params.totalChannels - Number of total channels connected to the server. + connect ( pServer, &CServer::ClientConnected, [=] ( const int iChanID, const QHostAddress RecHostAddr, const int iTotChans ) { + pRpcServer->BroadcastNotification ( "jamulusserver/clientConnected", + QJsonObject{ + { "id", iChanID }, + { "address", RecHostAddr.toString() }, + { "totalChannels", iTotChans }, + } ); + } ); + + /// @rpc_notification jamulusserver/clientDisconnected + /// @brief Emitted when a client has disconnected from the server. + /// @param {number} params.id - The channel ID assigned to the client. + connect ( + pServer, + &CServer::ClientDisconnectedRPC, + this, + [=] ( const int iChanID ) { + pRpcServer->BroadcastNotification ( "jamulusserver/clientDisconnected", + QJsonObject{ + { "id", iChanID }, + } ); + }, + Qt::QueuedConnection ); + + /// @rpc_notification jamulusserver/chatMessageReceived + /// @brief Emitted when a chat message is received. + /// @param {string} params.chatMessage - Chat message text. + connect ( pServer, &CServer::receivedChatMessage, [=] ( const QString& strChatText ) { + pRpcServer->BroadcastNotification ( "jamulusserver/chatMessageReceived", + QJsonObject{ + { "chatMessage", strChatText }, + } ); + } ); + + /// @rpc_method jamulusserver/broadcastChatMessage + /// @brief Sends a chat message to all connected clients. + /// @param {string} params.chatMessage - The chat message text. + /// @result {string} result - Always "ok". + pRpcServer->HandleMethod ( "jamulusserver/broadcastChatMessage", [=] ( const QJsonObject& params, QJsonObject& response ) { + auto jsonChatMessage = params["chatMessage"]; + if ( !jsonChatMessage.isString() ) + { + response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: chatMessage is not a string" ); + return; + } + + pServer->CreateAndSendChatTextForAllConChannels ( jsonChatMessage.toString() ); + response["result"] = "ok"; + } ); + /// @rpc_method jamulusserver/getRecorderStatus /// @brief Returns the recorder state. /// @param {object} params - No parameters (empty object). From 87db76ff46e2aa4d1575753312662f4be00260f0 Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Tue, 9 Jun 2026 18:09:29 +0200 Subject: [PATCH 2/6] remove RPC method "getAvailableMethods" --- docs/JSON-RPC.md | 17 ----------------- src/rpcserver.cpp | 26 -------------------------- src/rpcserver.h | 7 +++---- 3 files changed, 3 insertions(+), 47 deletions(-) diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index 6f9abcc011..04ed1e6951 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -95,23 +95,6 @@ Results: | result | string | "ok" on success | -### jamulus/getAvailableMethods - -Returns all available rpc methods. - -Parameters: - -| Name | Type | Description | -| --- | --- | --- | -| params | object | No parameters (empty object). | - -Results: - -| Name | Type | Description | -| --- | --- | --- | -| result.methods | array | All available methods. | - - ### jamulus/getMode Returns the current mode, i.e. whether Jamulus is running as a server or client. diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 3ff0192454..2c05c2f12d 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -66,16 +66,6 @@ CRpcServer::CRpcServer ( QObject* parent, QString strBindIP, int iPort, QString response["result"] = result; Q_UNUSED ( params ); } ); - - /// @rpc_method jamulus/getAvailableMethods - /// @brief Returns all available rpc methods. - /// @param {object} params - No parameters (empty object). - /// @result {array} result.methods - All available methods. - HandleMethod ( "jamulus/getAvailableMethods", [=] ( const QJsonObject& params, QJsonObject& response ) { - QJsonObject result = getAvailableMethods(); - response["result"] = result; - Q_UNUSED ( params ); - } ); } CRpcServer::~CRpcServer() @@ -234,22 +224,6 @@ void CRpcServer::HandleApiAuth ( QTcpSocket* pSocket, const QJsonObject& params, void CRpcServer::HandleMethod ( const QString& strMethod, CRpcHandler pHandler ) { mapMethodHandlers[strMethod] = pHandler; } -QJsonObject CRpcServer::getAvailableMethods() -{ - QJsonArray methods; - QMapIterator i ( mapMethodHandlers ); - - while ( i.hasNext() ) - { - i.next(); - methods.append ( i.key() ); - } - QJsonObject result{ - { "methods", methods }, - }; - return result; -} - void CRpcServer::ProcessMessage ( QTcpSocket* pSocket, QJsonObject message, QJsonObject& response ) { if ( !message["method"].isString() ) diff --git a/src/rpcserver.h b/src/rpcserver.h index 8e3fbff342..cf9da2706f 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -69,10 +69,9 @@ class CRpcServer : public QObject CRpcServer ( QObject* parent, QString strBindIP, int iPort, QString secret ); virtual ~CRpcServer(); - bool Start(); - void HandleMethod ( const QString& strMethod, CRpcHandler pHandler ); - void BroadcastNotification ( const QString& strMethod, const QJsonObject& aParams ); - QJsonObject getAvailableMethods(); + bool Start(); + void HandleMethod ( const QString& strMethod, CRpcHandler pHandler ); + void BroadcastNotification ( const QString& strMethod, const QJsonObject& aParams ); static QJsonObject CreateJsonRpcError ( int code, QString message ); From 130584b413fc81a646081f332de86dd02ff901c9 Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Tue, 9 Jun 2026 22:56:10 +0200 Subject: [PATCH 3/6] refactor jamulusserver/broadcastChatMessage --- src/server.cpp | 2 +- src/server.h | 2 +- src/serverrpc.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server.cpp b/src/server.cpp index b17563fece..0a694804c6 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1314,7 +1314,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, con } // external chat -void CServer::CreateAndSendChatTextForAllConChannels ( const QString& strChatText ) +void CServer::CreateAndSendExtChatTextForAllConChannels ( const QString& strChatText ) { // Send chat text to all connected clients --------------------------------- for ( int i = 0; i < iMaxNumChannels; i++ ) diff --git a/src/server.h b/src/server.h index e077d6026f..18ce25190a 100644 --- a/src/server.h +++ b/src/server.h @@ -191,7 +191,7 @@ class CServer : public QObject, public CServerSlots void SetEnableDelayPanning ( bool bDelayPanningOn ) { bDelayPan = bDelayPanningOn; } bool IsDelayPanningEnabled() { return bDelayPan; } - virtual void CreateAndSendChatTextForAllConChannels ( const QString& strChatText ); + void CreateAndSendExtChatTextForAllConChannels ( const QString& strChatText ); protected: // access functions for actual channels diff --git a/src/serverrpc.cpp b/src/serverrpc.cpp index 491f641f40..9a343e855d 100644 --- a/src/serverrpc.cpp +++ b/src/serverrpc.cpp @@ -107,7 +107,7 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare return; } - pServer->CreateAndSendChatTextForAllConChannels ( jsonChatMessage.toString() ); + pServer->CreateAndSendExtChatTextForAllConChannels ( jsonChatMessage.toString() ); response["result"] = "ok"; } ); From d628c27d94dda575ad84e18674730ff206b3a251 Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Sun, 14 Jun 2026 22:34:47 +0200 Subject: [PATCH 4/6] Refactor CServer::CreateAndSendChatTextForAllConChannels to remove duplicate code. Split reusable code into functions --- docs/JSON-RPC.md | 2 +- src/server.cpp | 29 ++++++++++++----------------- src/server.h | 5 +++-- src/serverrpc.cpp | 6 +++--- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index 04ed1e6951..3a5ea72bcc 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -657,7 +657,7 @@ Parameters: ### jamulusserver/chatMessageReceived -Emitted when a chat message is received. +Emitted when a chat message is received from either a Jamulus or RPC client and to be broadcast to all connected clients. Parameters: diff --git a/src/server.cpp b/src/server.cpp index 0a694804c6..c5bc347318 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1300,32 +1300,27 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, con const QString strActualMessageText = "(" + QTime::currentTime().toString ( "hh:mm:ss AP" ) + ") " + ChanName.toHtmlEscaped() + " " + strChatText.toHtmlEscaped(); + SendChatTextToAllChannels ( strActualMessageText ); +} - // Send chat text to all connected clients --------------------------------- +void CServer::SendChatTextToAllChannels ( const QString& strChatText ) +{ + // Send chat text to all channels ------------------------------------------- for ( int i = 0; i < iMaxNumChannels; i++ ) { - if ( vecChannels[i].IsConnected() ) - { - // send message - vecChannels[i].CreateChatTextMes ( strActualMessageText ); - } + SendChatTextToConChannel ( i, strChatText ); } - emit receivedChatMessage ( strActualMessageText ); + emit sentChatMessage ( strChatText ); } -// external chat -void CServer::CreateAndSendExtChatTextForAllConChannels ( const QString& strChatText ) +void CServer::SendChatTextToConChannel ( const int iCurChanID, const QString& strChatText ) { - // Send chat text to all connected clients --------------------------------- - for ( int i = 0; i < iMaxNumChannels; i++ ) + // Only send chat text if channel is connected ------------------------------ + if ( vecChannels[iCurChanID].IsConnected() ) { - if ( vecChannels[i].IsConnected() ) - { - // send message - vecChannels[i].CreateChatTextMes ( strChatText ); - } + // send message + vecChannels[iCurChanID].CreateChatTextMes ( strChatText ); } - emit receivedChatMessage ( strChatText ); } void CServer::CreateAndSendRecorderStateForAllConChannels() diff --git a/src/server.h b/src/server.h index 18ce25190a..5fe3edcadd 100644 --- a/src/server.h +++ b/src/server.h @@ -191,7 +191,7 @@ class CServer : public QObject, public CServerSlots void SetEnableDelayPanning ( bool bDelayPanningOn ) { bDelayPan = bDelayPanningOn; } bool IsDelayPanningEnabled() { return bDelayPan; } - void CreateAndSendExtChatTextForAllConChannels ( const QString& strChatText ); + void SendChatTextToAllChannels ( const QString& strChatText ); protected: // access functions for actual channels @@ -207,6 +207,7 @@ class CServer : public QObject, public CServerSlots virtual void CreateAndSendChanListForThisChan ( const int iCurChanID ); virtual void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ); + void SendChatTextToConChannel ( const int iCurChanID, const QString& strChatText ); virtual void CreateOtherMuteStateChanged ( const int iCurChanID, const int iOtherChanID, const bool bIsMuted ); @@ -332,7 +333,7 @@ class CServer : public QObject, public CServerSlots void ClientDisconnected ( const int iChID ); void ClientDisconnectedRPC ( const int iChID ); void ClientConnected ( const int iChID, const QHostAddress RecHostAddr, const int iTotChans ); - void receivedChatMessage ( const QString& strChatText ); + void sentChatMessage ( const QString& strChatText ); void SvrRegStatusChanged(); void AudioFrame ( const int iChID, const QString stChName, diff --git a/src/serverrpc.cpp b/src/serverrpc.cpp index 9a343e855d..771f61225c 100644 --- a/src/serverrpc.cpp +++ b/src/serverrpc.cpp @@ -86,9 +86,9 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare Qt::QueuedConnection ); /// @rpc_notification jamulusserver/chatMessageReceived - /// @brief Emitted when a chat message is received. + /// @brief Emitted when a chat message is received from either a Jamulus or RPC client and to be broadcast to all connected clients. /// @param {string} params.chatMessage - Chat message text. - connect ( pServer, &CServer::receivedChatMessage, [=] ( const QString& strChatText ) { + connect ( pServer, &CServer::sentChatMessage, [=] ( const QString& strChatText ) { pRpcServer->BroadcastNotification ( "jamulusserver/chatMessageReceived", QJsonObject{ { "chatMessage", strChatText }, @@ -107,7 +107,7 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare return; } - pServer->CreateAndSendExtChatTextForAllConChannels ( jsonChatMessage.toString() ); + pServer->SendChatTextToAllChannels ( jsonChatMessage.toString() ); response["result"] = "ok"; } ); From 2e33649c9afd25aefb4b6d926b98b568e0075631 Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Sun, 14 Jun 2026 23:17:03 +0200 Subject: [PATCH 5/6] Update RPC documentation on jamulusserver/broadcastChatMessage --- docs/JSON-RPC.md | 2 +- src/serverrpc.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index 3a5ea72bcc..bff0bfc92e 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -344,7 +344,7 @@ Results: ### jamulusserver/broadcastChatMessage -Sends a chat message to all connected clients. +Sends a message (as the server) to all connected clients. This can be used to broadcast messages from external sources (e.g. scripts or monitoring tools). Parameters: diff --git a/src/serverrpc.cpp b/src/serverrpc.cpp index 771f61225c..e504741b2f 100644 --- a/src/serverrpc.cpp +++ b/src/serverrpc.cpp @@ -96,7 +96,8 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare } ); /// @rpc_method jamulusserver/broadcastChatMessage - /// @brief Sends a chat message to all connected clients. + /// @brief Sends a message (as the server) to all connected clients. This can be used to broadcast messages from external sources (e.g. scripts or + /// monitoring tools). /// @param {string} params.chatMessage - The chat message text. /// @result {string} result - Always "ok". pRpcServer->HandleMethod ( "jamulusserver/broadcastChatMessage", [=] ( const QJsonObject& params, QJsonObject& response ) { From f7a4b86332217e17da5e28f0b66f699161cef159 Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Wed, 17 Jun 2026 15:32:07 +0200 Subject: [PATCH 6/6] Revert introduction of duplicate signal and handling in serverrpc slot --- src/server.cpp | 7 +------ src/server.h | 1 - src/serverrpc.cpp | 17 ++++++----------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/server.cpp b/src/server.cpp index c5bc347318..15f3d74e3f 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -874,12 +874,7 @@ void CServer::DecodeReceiveData ( const int iChanCnt, const int iNumClients ) // and emit the client disconnected signal if ( eGetStat == GS_CHAN_NOW_DISCONNECTED ) { - if ( JamController.GetRecordingEnabled() ) - { - emit ClientDisconnected ( iCurChanID ); // TODO do this outside the mutex lock? - } - // notify RPC server of disconnection - emit ClientDisconnectedRPC ( iCurChanID ); + emit ClientDisconnected ( iCurChanID ); // TODO do this outside the mutex lock? FreeChannel ( iCurChanID ); // note that the channel is now not in use diff --git a/src/server.h b/src/server.h index 5fe3edcadd..c87baba95c 100644 --- a/src/server.h +++ b/src/server.h @@ -331,7 +331,6 @@ class CServer : public QObject, public CServerSlots void Started(); void Stopped(); void ClientDisconnected ( const int iChID ); - void ClientDisconnectedRPC ( const int iChID ); void ClientConnected ( const int iChID, const QHostAddress RecHostAddr, const int iTotChans ); void sentChatMessage ( const QString& strChatText ); void SvrRegStatusChanged(); diff --git a/src/serverrpc.cpp b/src/serverrpc.cpp index e504741b2f..d1bf12f02f 100644 --- a/src/serverrpc.cpp +++ b/src/serverrpc.cpp @@ -73,17 +73,12 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare /// @rpc_notification jamulusserver/clientDisconnected /// @brief Emitted when a client has disconnected from the server. /// @param {number} params.id - The channel ID assigned to the client. - connect ( - pServer, - &CServer::ClientDisconnectedRPC, - this, - [=] ( const int iChanID ) { - pRpcServer->BroadcastNotification ( "jamulusserver/clientDisconnected", - QJsonObject{ - { "id", iChanID }, - } ); - }, - Qt::QueuedConnection ); + connect ( pServer, &CServer::ClientDisconnected, [=] ( const int iChanID ) { + pRpcServer->BroadcastNotification ( "jamulusserver/clientDisconnected", + QJsonObject{ + { "id", iChanID }, + } ); + } ); /// @rpc_notification jamulusserver/chatMessageReceived /// @brief Emitted when a chat message is received from either a Jamulus or RPC client and to be broadcast to all connected clients.