socketcluster-client
Advanced tools
Comparing version 18.2.2 to 18.3.0
@@ -20,4 +20,2 @@ const StreamDemux = require('stream-demux'); | ||
const isBrowser = typeof window !== 'undefined'; | ||
function AGClientSocket(socketOptions) { | ||
@@ -74,3 +72,2 @@ AsyncStreamEmitter.call( | ||
this.channelPrefix = opts.channelPrefix || null; | ||
this.disconnectOnUnload = opts.disconnectOnUnload == null ? true : opts.disconnectOnUnload; | ||
this.authTokenName = opts.authTokenName; | ||
@@ -187,6 +184,2 @@ | ||
if (isBrowser && this.disconnectOnUnload && typeof addEventListener !== 'undefined' && typeof removeEventListener !== 'undefined') { | ||
this._handleBrowserUnload(); | ||
} | ||
if (this.options.autoConnect) { | ||
@@ -228,41 +221,2 @@ this.connect(); | ||
AGClientSocket.prototype._handleBrowserUnload = async function () { | ||
let unloadHandler = () => { | ||
this.disconnect(); | ||
}; | ||
let isUnloadHandlerAttached = false; | ||
let attachUnloadHandler = () => { | ||
if (!isUnloadHandlerAttached) { | ||
isUnloadHandlerAttached = true; | ||
addEventListener('beforeunload', unloadHandler, false); | ||
} | ||
}; | ||
let detachUnloadHandler = () => { | ||
if (isUnloadHandlerAttached) { | ||
isUnloadHandlerAttached = false; | ||
removeEventListener('beforeunload', unloadHandler, false); | ||
} | ||
}; | ||
(async () => { | ||
let consumer = this.listener('connecting').createConsumer(); | ||
while (true) { | ||
let packet = await consumer.next(); | ||
if (packet.done) break; | ||
attachUnloadHandler(); | ||
} | ||
})(); | ||
(async () => { | ||
let consumer = this.listener('close').createConsumer(); | ||
while (true) { | ||
let packet = await consumer.next(); | ||
if (packet.done) break; | ||
detachUnloadHandler(); | ||
} | ||
})(); | ||
}; | ||
AGClientSocket.prototype._setAuthToken = function (data) { | ||
@@ -269,0 +223,0 @@ this._changeToAuthenticatedState(data.token); |
{ | ||
"name": "socketcluster-client", | ||
"description": "SocketCluster JavaScript client", | ||
"version": "18.2.2", | ||
"version": "18.3.0", | ||
"homepage": "https://socketcluster.io/", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -161,3 +161,2 @@ SocketCluster JavaScript client | ||
channelPrefix: null, | ||
disconnectOnUnload: true, | ||
autoReconnectOptions: { | ||
@@ -164,0 +163,0 @@ initialDelay: 10000, //milliseconds |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215358
3400
230