From 3cdc268b0e4f150fcc65bbc643c018e465006ab6 Mon Sep 17 00:00:00 2001 From: Sebastian Scheibner Date: Sat, 26 Aug 2023 17:41:13 +0200 Subject: [PATCH] Updated JSON RPC service (markdown) --- JSON-RPC-service.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/JSON-RPC-service.md b/JSON-RPC-service.md index ca29100..2c60e5c 100644 --- a/JSON-RPC-service.md +++ b/JSON-RPC-service.md @@ -25,12 +25,22 @@ From the command line: `echo '{"jsonrpc":"2.0","method":"listGroups","id":"my special mark"}' | signal-cli -u +33123456789 jsonRpc` -Like in dbus daemon mode, messages are automatically received in jsonRpc mode. Incoming messages are sent as JSON-RPC notifications. +## Receiving messages + +Like in dbus daemon mode, messages are automatically received in jsonRpc mode (`--receive-mode=automatic`). Incoming messages are sent as JSON-RPC notifications. Example: `{"jsonrpc":"2.0","method":"receive","params":{"envelope":{"source":"+33123456789","sourceNumber":"+33123456789","sourceUuid":"uuid","sourceName":"name","sourceDevice":1,"timestamp":1631458508784,"dataMessage":{"timestamp":1631458508784,"message":"foobar","expiresInSeconds":0,"viewOnce":false,"mentions":[],"attachments":[],"contacts":[]}}}}` +In order to not miss messages, automatic receiving of messages can be disabled with the `--receive-mode=manual` parameter. +REQUEST: `{"jsonrpc":"2.0","id":"id","method":"subscribeReceive"}` +RESPONSE: `{"jsonrpc":"2.0","result":0,"id":"id"}` + +Messages are then sent similar to the automatic mode, but wrapped in a subscription response object: +`{"jsonrpc":"2.0","method":"receive","params":{"subscription":0,"result":{"envelope":{"source":"+33123456789","sourceNumber":"+33123456789","sourceUuid":"uuid","sourceName":"name","sourceDevice":2,"timestamp":1693064367769,"syncMessage":{"sentMessage":{"destination":"+33123456789","destinationNumber":"+33123456789","destinationUuid":"uuid","timestamp":1693064367769,"message":"j","expiresInSeconds":0,"viewOnce":false}}},"account":"+33123456789"}}}` + + ## Commands The commands available for the JSON-RPC mode are the same as the cli commands (except `register`, `verify` and `link`). The `method` field is the command name and the parameters can be sent as the `params` object.