Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/JSON-RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,24 @@ Results:
| result.registrationStatus | string | The server registration status as string (see ESvrRegStatus and SerializeRegistrationStatus). |


### jamulusserver/privateChatMessage

Sends a chat message to a single connected client.

Parameters:

| Name | Type | Description |
| --- | --- | --- |
| params.chatMessage | string | The chat message text. |
| params.id | number | The client's channel id. |

Results:

| Name | Type | Description |
| --- | --- | --- |
| result | string | Always "ok". |


### jamulusserver/restartRecording

Restarts the recording into a new directory.
Expand Down
18 changes: 18 additions & 0 deletions src/serverrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,24 @@ CServerRpc::CServerRpc ( CServer* pServer, CRpcServer* pRpcServer, QObject* pare
response["result"] = "acknowledged";
Q_UNUSED ( params );
} );

/// @rpc_method jamulusserver/privateChatMessage
/// @brief Sends a chat message to a single connected client.
/// @param {string} params.chatMessage - The chat message text.
/// @param {number} params.id - The client's channel id.
/// @result {string} result - Always "ok".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we document errors? It should not rather be "ok" on success, no?

pRpcServer->HandleMethod ( "jamulusserver/privateChatMessage", [=] ( const QJsonObject& params, QJsonObject& response ) {
auto jsonChatMessage = params["chatMessage"];
const int id = params["id"].toInt();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs validating, probably in CServer::CreateAndSendChatTextToChannel

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CServer::CreateAndSendChatTextToChannel does actually validate the channel ID and will only send the message if the channel is present. It was copied from the original function for sending chat messages.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented there.

@ann0see ann0see Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that it should then not return OK.
Furthermore, if the id is not given it "defaults" to 0.

At least if id is unset, it should fail.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we have a max message length for UDP CM chat messages? The JSONRPC request message length should be validated against that and an error returned.

And yes, it needs to return an error for an incorrect channel id.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't JSON-RPC using a TCP socket, if so, it should be of basically "infinite" length?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to not overrun the existing request expectations.

if ( !jsonChatMessage.isString() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: chatMessage is not a string" );
return;
}

pServer->SendChatTextToConChannel ( id, jsonChatMessage.toString() );
response["result"] = "ok";
} );
}

#if defined( Q_OS_MACOS ) && QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
Expand Down
Loading