Skip to content

Commit 3f41bbb

Browse files
cmaglieper1234
andauthored
Updated readme (#5)
* Updated readme * Apply suggestion from @per1234 Co-authored-by: Per Tillisch <accounts@perglass.com> * Apply suggestion from @per1234 Co-authored-by: Per Tillisch <accounts@perglass.com> * Apply suggestion from @per1234 Co-authored-by: Per Tillisch <accounts@perglass.com> --------- Co-authored-by: Per Tillisch <accounts@perglass.com>
1 parent 80b8bbd commit 3f41bbb

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

README.md

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,12 @@
1-
## MessagePack RPC Connection `msgpackrpc`
1+
# `arduino-router` is a MessagePack RPC Router
22

3-
This package implements a MessagePack RPC point-to-point communication. The actors on each side of the communication can perform RPC calls to the other side so, technically, they can act simultaneously as client or server.\
4-
By the way, for the sake of simplicity, from now on we will refer to them simply with "client").
3+
This module implements a MessagePack RPC Router that allows RPC calls between multiple MessagePack RPC clients, connected together in a star topology network, where the Router is the central node.
54

6-
The protocol supported is defined here https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md. We have 3 types of messages defined as:
5+
Each client can connect to the Router and expose RPC services by registering its methods using a special RPC call implemented in the Router. During normal operation, when the Router receives an RPC request, it redirects the request to the client that has previously registered the corresponding method and it will forward back the response to the client that originated the RPC request.
76

8-
- REQUEST: this message is an array of 4 elements containing in order:
9-
1. `type`: Fixed as number `0` (to identify the message as a REQUEST).
10-
2. `msgid`: A message ID, a 32-bit unsigned integer used as a sequence number to match the response (the server's response to the REQUEST will have the same `msgid`).
11-
3. `method`: A string containing the called method name.
12-
4. `params`: An array of the function arguments.
7+
To understand more about MessagePack encoding see: <https://msgpack.org/>
138

14-
- RESPONSE: this message is an array of 4 elements containing in order:
15-
1. `type`: Fixed as number `1` (to identify the message as a RESPONSE).
16-
2. `msgid`: A message ID.
17-
3. `error`: The error returned from the method, or `null` if the method was successful.
18-
4. `result`: The result of the method. It should be `null` if an error occurred.
19-
20-
- NOTIFICATION: this message is an array of 3 elements containing in order:
21-
1. `type`: Fixed number `2` (to identify this message as a NOTIFICATION).
22-
2. `methods`: The method name.
23-
3. `params`: An array of the function parameters.
24-
25-
### RPC Request cancelation support
26-
27-
The MessagePack RPC protocol implemented in this package provides also a way for a client to cancel a REQUEST. To do so the client must send a NOTIFICATION to the `$/cancel` method with a single parameter matching the `msgid` of the REQUEST to cancel.
28-
29-
```
30-
[2 "$/cancel" [ MSGID ]]
31-
```
32-
33-
The server will send an interrupt to the subroutine handling the original REQUEST to inform that the client is no longer interested in the RESPONSE. The server could return immediately an empty RESPONSE with an "interrupted" error, or it may ignore the cancel notification, in this latter case the cancelation will not produce any visible effect.
34-
35-
## MessagePack RPC Router `msgpackrouter`
36-
37-
This package implements a MessagePack RPC Router. A Router allows RPC calls between multiple MessagePack RPC clients, connected together in a star topology network, where the Router is the central node.
38-
39-
Each client can connect to the Router and expose RPC services by registering his methods using a special RPC call implemented in the Router. During normal operation, when the Router receives an RPC request, it redirects the request to the client that has previously registered the corresponding method and it will forwards back the response to the client that originated the RPC request.
9+
This module provides also a MessagePack RPC client in the `msgpackrpc` package. To get more details about MessagePack RPC and this implementation see [here](msgpackrpc/README.md).
4010

4111
### Methods implemented in the Router
4212

msgpackrpc/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# A MessagePack RPC client/server implementation.
2+
3+
This package implements a MessagePack RPC point-to-point communication. The actors on each side of the communication can perform RPC calls to the other side so, technically, they can act simultaneously as client or server. By the way, for the sake of simplicity, from now on we will refer to them simply with "client".
4+
5+
The protocol supported is defined here https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md. We have 3 types of messages defined as:
6+
7+
- REQUEST: this message is an array of 4 elements containing in order:
8+
1. `type`: Fixed as number `0` (to identify the message as a REQUEST).
9+
2. `msgid`: A message ID, a 32-bit unsigned integer used as a sequence number to match the response (the server's response to the REQUEST will have the same `msgid`).
10+
3. `method`: A string containing the called method name.
11+
4. `params`: An array of the function arguments.
12+
13+
- RESPONSE: this message is an array of 4 elements containing in order:
14+
1. `type`: Fixed as number `1` (to identify the message as a RESPONSE).
15+
2. `msgid`: A message ID.
16+
3. `error`: The error returned from the method, or `null` if the method was successful.
17+
4. `result`: The result of the method. It should be `null` if an error occurred.
18+
19+
- NOTIFICATION: this message is an array of 3 elements containing in order:
20+
1. `type`: Fixed number `2` (to identify this message as a NOTIFICATION).
21+
2. `methods`: The method name.
22+
3. `params`: An array of the function parameters.
23+
24+
### RPC Request cancelation support
25+
26+
The MessagePack RPC protocol implemented in this package provides also a way for a client to cancel a REQUEST. To do so the client must send a NOTIFICATION to the `$/cancel` method with a single parameter matching the `msgid` of the REQUEST to cancel.
27+
28+
```
29+
[2 "$/cancel" [ MSGID ]]
30+
```
31+
32+
The server will send an interrupt to the subroutine handling the original REQUEST to inform that the client is no longer interested in the RESPONSE. The server could return immediately an empty RESPONSE with an "interrupted" error, or it may ignore the cancel notification, in this latter case the cancelation will not produce any visible effect.

0 commit comments

Comments
 (0)