WICG / local-peer-to-peer

↔️ Proposal for local communication between browsers without the aid of a server.
https://wicg.github.io/local-peer-to-peer/
Other
62 stars 6 forks source link

Replace LP2PReceiver.ontransport with LP2PQuicTransportListener #33

Closed backkem closed 5 months ago

backkem commented 6 months ago

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:

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( { /* ... */ } );

Preview | Diff