@bloks/link-session-manager
Advanced tools
Comparing version 0.2.642 to 0.2.643
/** | ||
* proton-link-session-manager v0.2.642 | ||
* proton-link-session-manager v0.2.643 | ||
* https://github.com/greymass/proton-link-session-manager | ||
@@ -4,0 +4,0 @@ * |
/** | ||
* proton-link-session-manager v0.2.642 | ||
* proton-link-session-manager v0.2.643 | ||
* https://github.com/greymass/proton-link-session-manager | ||
@@ -198,3 +198,3 @@ * | ||
}; | ||
this_1.realWs.addEventListener(stdEvent, onEvent.bind(this_1)); | ||
this_1.realWs.addEventListener(stdEvent, onEvent); | ||
}; | ||
@@ -246,4 +246,4 @@ var this_1 = this; | ||
case 2: | ||
if (this.netInfoState) { | ||
this.attachConnectivityEvents(); | ||
if (this.netInfoState && !this.unsubscribeNetInfo) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(this.onConnectivityUpdate); | ||
} | ||
@@ -255,28 +255,22 @@ return [2 /*return*/]; | ||
}; | ||
RobustWebSocket.prototype.attachConnectivityEvents = function () { | ||
var _this = this; | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo && this.netInfoState) { | ||
var onConnectivity = function (state) { | ||
if (!state) { | ||
return; | ||
} | ||
// Offline -> Online | ||
var isOnline = state.isConnected && !(_this.netInfoState && _this.netInfoState.isConnected); | ||
if (isOnline && _this.reconnectWhenOnlineAgain) { | ||
_this.clearPendingReconnectIfNeeded(); | ||
_this.reconnect({ code: 0 }); | ||
} | ||
// Online -> Offline | ||
var isOffline = !state.isConnected && _this.netInfoState && _this.netInfoState.isConnected; | ||
if (isOffline) { | ||
_this.reconnectWhenOnlineAgain = true; | ||
if (_this.realWs) { | ||
_this.realWs.close(1000); | ||
} | ||
} | ||
// Update to latest | ||
_this.netInfoState = state; | ||
}; | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(onConnectivity.bind(this)); | ||
RobustWebSocket.prototype.onConnectivityUpdate = function (state) { | ||
if (!state) { | ||
return; | ||
} | ||
// Offline -> Online | ||
var isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected); | ||
if (isOnline && this.reconnectWhenOnlineAgain) { | ||
this.clearPendingReconnectIfNeeded(); | ||
this.reconnect({ code: 0 }); | ||
} | ||
// Online -> Offline | ||
var isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected; | ||
if (isOffline) { | ||
this.reconnectWhenOnlineAgain = true; | ||
if (this.realWs) { | ||
this.realWs.close(1000); | ||
} | ||
} | ||
// Update to latest | ||
this.netInfoState = state; | ||
}; | ||
@@ -283,0 +277,0 @@ RobustWebSocket.prototype.send = function (data) { |
/** | ||
* proton-link-session-manager v0.2.642 | ||
* proton-link-session-manager v0.2.643 | ||
* https://github.com/greymass/proton-link-session-manager | ||
@@ -171,3 +171,3 @@ * | ||
}; | ||
this.realWs.addEventListener(stdEvent, onEvent.bind(this)); | ||
this.realWs.addEventListener(stdEvent, onEvent); | ||
} | ||
@@ -196,31 +196,26 @@ if (this.opts.netInfo) { | ||
} | ||
if (this.netInfoState) { | ||
this.attachConnectivityEvents(); | ||
if (this.netInfoState && !this.unsubscribeNetInfo) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(this.onConnectivityUpdate); | ||
} | ||
} | ||
attachConnectivityEvents() { | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo && this.netInfoState) { | ||
const onConnectivity = (state) => { | ||
if (!state) { | ||
return; | ||
} | ||
// Offline -> Online | ||
const isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected); | ||
if (isOnline && this.reconnectWhenOnlineAgain) { | ||
this.clearPendingReconnectIfNeeded(); | ||
this.reconnect({ code: 0 }); | ||
} | ||
// Online -> Offline | ||
const isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected; | ||
if (isOffline) { | ||
this.reconnectWhenOnlineAgain = true; | ||
if (this.realWs) { | ||
this.realWs.close(1000); | ||
} | ||
} | ||
// Update to latest | ||
this.netInfoState = state; | ||
}; | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(onConnectivity.bind(this)); | ||
onConnectivityUpdate(state) { | ||
if (!state) { | ||
return; | ||
} | ||
// Offline -> Online | ||
const isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected); | ||
if (isOnline && this.reconnectWhenOnlineAgain) { | ||
this.clearPendingReconnectIfNeeded(); | ||
this.reconnect({ code: 0 }); | ||
} | ||
// Online -> Offline | ||
const isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected; | ||
if (isOffline) { | ||
this.reconnectWhenOnlineAgain = true; | ||
if (this.realWs) { | ||
this.realWs.close(1000); | ||
} | ||
} | ||
// Update to latest | ||
this.netInfoState = state; | ||
} | ||
@@ -227,0 +222,0 @@ send(data) { |
{ | ||
"name": "@bloks/link-session-manager", | ||
"description": "Session management for signature providers when receiving requests using the Anchor Link protocol", | ||
"version": "0.2.642", | ||
"version": "0.2.643", | ||
"homepage": "https://github.com/greymass/proton-link-session-manager", | ||
@@ -6,0 +6,0 @@ "license": "BSD-3-Clause", |
@@ -128,3 +128,3 @@ import NetInfo, {NetInfoState, NetInfoSubscription} from '@react-native-community/netinfo' | ||
this.realWs.addEventListener(stdEvent, onEvent.bind(this)) | ||
this.realWs.addEventListener(stdEvent, onEvent) | ||
} | ||
@@ -159,37 +159,30 @@ | ||
if (this.netInfoState) { | ||
this.attachConnectivityEvents() | ||
if (this.netInfoState && !this.unsubscribeNetInfo) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(this.onConnectivityUpdate) | ||
} | ||
} | ||
attachConnectivityEvents() { | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo && this.netInfoState) { | ||
const onConnectivity = (state) => { | ||
if (!state) { | ||
return | ||
} | ||
onConnectivityUpdate(state: NetInfoState) { | ||
if (!state) { | ||
return | ||
} | ||
// Offline -> Online | ||
const isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected) | ||
if (isOnline && this.reconnectWhenOnlineAgain) { | ||
this.clearPendingReconnectIfNeeded() | ||
this.reconnect({code: 0}) | ||
} | ||
// Offline -> Online | ||
const isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected) | ||
if (isOnline && this.reconnectWhenOnlineAgain) { | ||
this.clearPendingReconnectIfNeeded() | ||
this.reconnect({code: 0}) | ||
} | ||
// Online -> Offline | ||
const isOffline = | ||
!state.isConnected && this.netInfoState && this.netInfoState.isConnected | ||
if (isOffline) { | ||
this.reconnectWhenOnlineAgain = true | ||
if (this.realWs) { | ||
this.realWs.close(1000) | ||
} | ||
} | ||
// Update to latest | ||
this.netInfoState = state | ||
// Online -> Offline | ||
const isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected | ||
if (isOffline) { | ||
this.reconnectWhenOnlineAgain = true | ||
if (this.realWs) { | ||
this.realWs.close(1000) | ||
} | ||
} | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(onConnectivity.bind(this)) | ||
} | ||
// Update to latest | ||
this.netInfoState = state | ||
} | ||
@@ -196,0 +189,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
101761
1747