vardius / peer-cdn

Lightweight library providing peer to peer CDN functionality
https://rafallorenz.com/peer-cdn
MIT License
68 stars 12 forks source link

client.postMessage browser support #13

Open vardius opened 6 years ago

vardius commented 6 years ago

according to the client.postMessage() documentation and presented example, given solution should work, however client never gets worker message on:

vardius commented 6 years ago

To test: https://stackoverflow.com/a/51199092/2160958

Should we use

self.clients.matchAll().then(function (clients){
    clients.forEach(function(client){
        client.postMessage({
            msg: "Hey I just got a fetch from you!",
            url: event.request.url
        });
    });
}); 

instead of

https://github.com/vardius/peer-cdn/blob/8d105c97f8eb10691db8b71e09dc75084d900161/src/plugins/Delegate.js#L33

What is the support for Clients.get()? Maybe iterating over clients and finding the one matching our id is a better way of doing this (for now) then getting client by id ?

Would love to hear someones opinion here. Any help appreciated.