Closed RangerMauve closed 3 years ago
Do extension messages work similarly for most protocols?
I don't know if extension messages are a feature of all protocols.
I know that BitTorrent has then and I think they're sent at the torrent-replication layer. hypercore-protocol actually has two layers of extension messages, one at the top level of the protocol, and one that's per hypercore replication channel that's multiplexed over the connection.
I was thinking this's be the hypercore channel extension messages to start.
I don't think IPFS has extension messages because they expect you to use libp2p directly.
Similarly, I don't think EarthStar has extension messages since it's replication seems to be based on HTTP requests.
This has been implemented as of #25 😁
Ended up using a special folder
called /$/extensions/
to do Extension stuff. You can subscribe to a text/event-stream
of all extension messages, or POST
to /$/extensions/NAME_HERE
to broadcast data out to all peers.
We need an API for listing peer metadata as well as sending extension messages to peers.
I propose something like
The
PEER
method will list the metadata about the peers you're connected with. Maybe there should be something here for filtering peers by which ones have a certain extension? Maybe we could list which extensions peers are registered on too?The
EXTENSION-REGISTER
will register an extension message handler if one doesn't exist. It will then start an event source stream and send new events down the wire. This should be used with the EventSource API in browsers. We need to figure out a way to specify which peer an event has come from. Maybe in the message name? Maybe in the lastMessageId?Lastly,
EXTENSION-SEND
will send out an extension message. The body will be used as the extension message contents. You can optionally specify a peer's id in the querystring to send to a specific peer (or multiple specific peers), or leave the querystring blank to broadcast to everyone. This is similar to a POST.How does that sound? I'm mostly iffy about the peer info.
cc @DeltaF1 @calm-rad