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

Relationship with service worker needs clarification. #49

Open steely-glint opened 1 month ago

steely-glint commented 1 month ago

Our experience of building similar things in the IoT space with webRTC (cameras, baby monitors etc.) Shows that there is a lot of value in being able to use P2P communications within a service worker. The upper layers do a 'normal' fetch() - but the service worker sends it to a local peer instead of a cloud service - this means the UI code can remain the same for both local/offline and remote/online cases.

backkem commented 1 month ago

Good point. The current specification defines the API to be available in both the Window and Worker context:

[Exposed=(Window,Worker), SecureContext]

I'm not sure if we need to add anything specific to also expose it in the service worker context. I'd have to do some research on that.

wangw-1991 commented 1 month ago

Exposed=Worker means this API is available in all worker contexts, including dedicated worker, shared worker and service worker, see blow link for details: https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/IDLExtendedAttributes.md#exposed

backkem commented 1 month ago

Thanks for digging that up @wangw-1991. For me this satisfies the requirement. Let me know if you agree @steely-glint.