diff options
| author | Ricardo Arturo Cabral Mejía <me@ricardocabral.io> | 2022-08-16 22:57:22 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-16 22:57:22 -0400 |
| commit | ef059e0fdee06686d2a1f996aebeb092749fc976 (patch) | |
| tree | 9f875681e9ccf895fcc1602ad37b00d67ca8b27e /27.md | |
| parent | f6346b6e2265013acdcbc6dacd4a00b69394da0c (diff) | |
NIP-27 Multicasting
Diffstat (limited to '27.md')
| -rw-r--r-- | 27.md | 67 |
1 files changed, 67 insertions, 0 deletions
| @@ -0,0 +1,67 @@ | |||
| 1 | NIP-27 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Multicasting | ||
| 5 | ------------ | ||
| 6 | |||
| 7 | `draft` `optional` `author:cameri` | ||
| 8 | |||
| 9 | A new tag `m` meaning `multicast group` allow for events to be addressed to a | ||
| 10 | group of clients simultaneously. Multicast in this scenario can be one-to-many | ||
| 11 | or many-to-many. | ||
| 12 | |||
| 13 | A relay MUST forward events containing `m` tags strictly to clients subscribed | ||
| 14 | with a tag filter `#m` containing at least one of the values of such tags and | ||
| 15 | refrain from forwarding such events to clients without such filter. The value | ||
| 16 | of an `m` tag is case-sensitive. | ||
| 17 | |||
| 18 | A client SHOULD send events containing `m` tags only to relays that explicitly | ||
| 19 | support NIP-27. A NIP-16 supporting client MAY test for the capability by | ||
| 20 | subscribing twice to a relay with and without the tag filter `#m` respectively | ||
| 21 | and sending an ephemeral event with a random `m` tag of equal value. | ||
| 22 | |||
| 23 | ## Events | ||
| 24 | |||
| 25 | Clients targeting a multicast group MAY include an `m` tag with a value set to | ||
| 26 | an arbitrary string representing the multicast group. | ||
| 27 | |||
| 28 | Suppose that Alice wants to multicast an event to a very special multicast group | ||
| 29 | that covers specific topics. The multicast group is identified by the following | ||
| 30 | string: `00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048` | ||
| 31 | |||
| 32 | Alice would construct the following message and sends it to her favorite relay | ||
| 33 | which happens to support multicasting: | ||
| 34 | |||
| 35 | ```json | ||
| 36 | [ | ||
| 37 | "EVENT", | ||
| 38 | { | ||
| 39 | "id": "<id>", | ||
| 40 | "pubkey": "<Alice's pubkey>", | ||
| 41 | "created_at": 1231469640, | ||
| 42 | "content": "Let's get the conversation started", | ||
| 43 | "tags": [ | ||
| 44 | ["m", "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"], | ||
| 45 | ], | ||
| 46 | "sig": "<sig>" | ||
| 47 | } | ||
| 48 | ] | ||
| 49 | ``` | ||
| 50 | |||
| 51 | ## Subscriptions | ||
| 52 | |||
| 53 | Clients subscribing to a multicast group MUST include an `#m` tag filter with | ||
| 54 | an array of multicast groups as values. | ||
| 55 | |||
| 56 | Suppose that Bob and Charlie both share Alice's interest and would like to stay | ||
| 57 | up to date. Both would construct the following message to subscribe: | ||
| 58 | |||
| 59 | ``` | ||
| 60 | [ | ||
| 61 | "REQ", | ||
| 62 | "<subscriptionId>", | ||
| 63 | { | ||
| 64 | "#m": ["00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"] | ||
| 65 | } | ||
| 66 | ] | ||
| 67 | ``` | ||