mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-21 13:44:18 +00:00
Updated JSON RPC service (markdown)
parent
b16b9f4322
commit
caf9ded7bb
@ -1,11 +1,17 @@
|
||||
signal-cli provides a [JSON-RPC](https://www.jsonrpc.org/specification) based API that accepts input on STDIN and responds on STDOUT.
|
||||
The JSON-RPC mode is intended to make it easier to embed signal-cli in other applications.
|
||||
signal-cli provides a [JSON-RPC](https://www.jsonrpc.org/specification) based API with the `jsonRpc` and `daemon` commands.
|
||||
- `jsonRpc` command accepts input on STDIN and responds on STDOUT.
|
||||
This is intended to make it easier to embed signal-cli in other applications.
|
||||
|
||||
`signal-cli -u _USERNAME_ jsonRpc`
|
||||
- `daemon` command provides a UNIX or TCP socket and can handle requests from multiple clients.
|
||||
|
||||
`signal-cli -u _USERNAME_ daemon --socket` or for multi-account mode `signal-cli daemon --socket`
|
||||
|
||||
## Basic usage
|
||||
`signal-cli -u _USERNAME_ jsonRpc`
|
||||
|
||||
|
||||
In JSON-RPC mode, signal-cli will read requests from stdin. Every requests must be a JSON object in a single line.
|
||||
Requests must have a unique "id" value to be able to match the reponse to the corresponding request.
|
||||
Requests must have a unique "id" value to be able to match the response to the corresponding request.
|
||||
|
||||
Example:
|
||||
|
||||
@ -17,7 +23,7 @@ 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 to stdout as JSON-RPC notifications.
|
||||
Like in dbus daemon mode, messages are automatically received in jsonRpc mode. Incoming messages are sent as JSON-RPC notifications.
|
||||
|
||||
Example:
|
||||
|
||||
@ -51,14 +57,4 @@ REQUEST: `{"jsonrpc":"2.0","method":"sendSyncRequest","id":9}`
|
||||
RESPONSE: `{"jsonrpc":"2.0","result":{},"id":9}`
|
||||
|
||||
REQUEST: `{"jsonrpc":"2.0"}`
|
||||
RESPONSE: `{"jsonrpc":"2.0","error":{"code":-32600,"message":"method field must be set","data":null},"id":null}`
|
||||
|
||||
## Communicate with named pipes
|
||||
It is possible to communicate with the server over the network using named pipes. For example, the following commands set up a JSON RPC signal-cli server listening on local port 9182:
|
||||
|
||||
mkfifo sigsocket
|
||||
(while true; do nc -l -p 9182 <sigsocket; done) | signal-cli -u +123456789 jsonRpc >sigsocket &
|
||||
|
||||
To communicate with the server from the same machine (localhost), issue the command:
|
||||
|
||||
`nc localhost 9182` <-- note that the port number must match the port number above
|
||||
RESPONSE: `{"jsonrpc":"2.0","error":{"code":-32600,"message":"method field must be set","data":null},"id":null}`
|
||||
Loading…
x
Reference in New Issue
Block a user