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

@@ -125,6 +125,10 @@ var init = function (client, cb) {
}, true);
self.tabs[client.id].msgEv = msgEv;
self.tabs[client.id].close = function () {
Rpc._removeClient(client.id);
};
});
});
};
@@ -139,6 +143,11 @@ self.addEventListener('message', function (e) {
init(e.source, function () {
postMsg(e.source, 'SW_READY');
});
} else if (e.data === "CLOSE") {
if (tabs[cId] && tabs[cId].close) {
console.log('leave');
tabs[cId].close();
}
} else if (self.tabs[cId] && self.tabs[cId].msgEv) {
self.tabs[cId].msgEv.fire(e);
}