|
1 | | -## MessagePack RPC Connection `msgpackrpc` |
| 1 | +# `arduino-router` is a MessagePack RPC Router |
2 | 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.\ |
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. |
5 | 4 |
|
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. |
7 | 6 |
|
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/> |
13 | 8 |
|
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). |
40 | 10 |
|
41 | 11 | ### Methods implemented in the Router |
42 | 12 |
|
|
0 commit comments