Test service worker and shared worker store

This commit is contained in:
yflory
2018-06-06 15:58:43 +02:00
parent 9c5ad795e1
commit 6ab29f8f3a
10 changed files with 927 additions and 548 deletions

View File

@@ -1,4 +1,5 @@
var id = Math.floor(Math.random()*100000);
var id;
//= Math.floor(Math.random()*100000);
var postMsg = function (client, data) {
client.postMessage(data);
@@ -42,6 +43,9 @@ self.addEventListener('message', function (e) {
console.log(e.source);
var cId = e.source.id;
if (e.data === "INIT") {
if (!id) {
id = Math.floor(Math.random()*100000);
}
broadcast(cId + ' has joined!', [cId]);
postMsg(e.source, {state: 'READY'});
postMsg(e.source, "Welcome to SW " + id + "!");