Disconnect from shared/service worker

This commit is contained in:
yflory
2018-06-08 16:45:07 +02:00
parent f05e2225d6
commit 02b282a1a5
4 changed files with 38 additions and 1 deletions

View File

@@ -127,6 +127,10 @@ var init = function (client, cb) {
}, true);
client.msgEv = msgEv;
client.close = function () {
Rpc._removeClient(client.id);
};
});
});
};
@@ -147,6 +151,11 @@ onconnect = function(e) {
init(client, function () {
postMsg(client, 'SW_READY');
});
} else if (e.data === "CLOSE") {
if (client && client.close) {
console.log('leave');
client.close();
}
} else if (client && client.msgEv) {
client.msgEv.fire(e);
}