This PR writes out the last option mentioned in #32. LP2PReciever.ontransport is removed in favor of a LP2PQuicTransportListener object. This allows a QuicTransport to be created/accepted by both the LP2PReceiver and LP2PRequest. It also replaces the EventHandler with a ReadableStream as mentioned in #30.
Do we find this to be an improvement overall? The new code examples look reasonable to me. The downsides I see are:
LP2PQuicTransportListener is quite long.
You have to know about the LP2PQuicTransport and LP2PQuicTransportListener constructors in addition to LP2PReceiver and LP2PRequest.
There is a naming difference between LP2PReceiver and LP2PQuicTransportListener. However, that does reflect their different way of working.
One way to address these is to add shorthand helpers as existed in the original explainer, pseudo code example:
// Peer A
const listener = navigator.lp2p.listen( { /* ... */ } );
// Peer B
const transport = navigator.lp2p.connect( { /* ... */ } );
This PR writes out the last option mentioned in #32.
LP2PReciever.ontransport
is removed in favor of aLP2PQuicTransportListener
object. This allows a QuicTransport to be created/accepted by both theLP2PReceiver
andLP2PRequest
. It also replaces theEventHandler
with aReadableStream
as mentioned in #30.Do we find this to be an improvement overall? The new code examples look reasonable to me. The downsides I see are:
LP2PQuicTransportListener
is quite long.LP2PQuicTransport
andLP2PQuicTransportListener
constructors in addition toLP2PReceiver
andLP2PRequest
.LP2PReceiver
andLP2PQuicTransportListener
. However, that does reflect their different way of working.One way to address these is to add shorthand helpers as existed in the original explainer, pseudo code example:
Preview | Diff