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

@@ -768,7 +768,7 @@ define([
var msgEv = Util.mkEvent();
var postMsg, worker;
Nthen(function (waitFor2) {
if (SharedWorker) {
if (typeof(SharedWorker) !== "undefined") {
worker = new SharedWorker('/common/outer/sharedworker.js?' + urlArgs);
worker.onerror = function (e) {
console.error(e);
@@ -783,6 +783,10 @@ define([
worker.port.postMessage(data);
};
postMsg('INIT');
window.addEventListener('beforeunload', function () {
postMsg('CLOSE');
});
} else if (false && 'serviceWorker' in navigator) {
var initializing = true;
var stopWaiting = waitFor2(); // Call this function when we're ready
@@ -830,6 +834,10 @@ define([
}).catch(function(error) {
/**/console.log('Registration failed with ' + error);
});
window.addEventListener('beforeunload', function () {
postMsg('CLOSE');
});
} else if (Worker) {
worker = new Worker('/common/outer/webworker.js?' + urlArgs);
worker.onmessage = function (ev) {