@bloks/link-session-manager
Advanced tools
Comparing version 0.2.625 to 0.2.626
/** | ||
* proton-link-session-manager v0.2.625 | ||
* proton-link-session-manager v0.2.626 | ||
* https://github.com/greymass/proton-link-session-manager | ||
@@ -4,0 +4,0 @@ * |
/** | ||
* proton-link-session-manager v0.2.625 | ||
* proton-link-session-manager v0.2.626 | ||
* https://github.com/greymass/proton-link-session-manager | ||
@@ -214,3 +214,3 @@ * | ||
console.log(10); | ||
this.attachConnectivityEvents(); | ||
this.initializeConnectivity(); | ||
} | ||
@@ -229,6 +229,34 @@ }; | ||
}; | ||
RobustWebSocket.prototype.initializeConnectivity = function () { | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
var _a; | ||
return tslib.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!this.opts.netInfo) { | ||
return [2 /*return*/]; | ||
} | ||
if (!!this.netInfoState) return [3 /*break*/, 2]; | ||
_a = this; | ||
return [4 /*yield*/, this.opts.netInfo.fetch()]; | ||
case 1: | ||
_a.netInfoState = _b.sent(); | ||
_b.label = 2; | ||
case 2: | ||
if (this.netInfoState) { | ||
this.attachConnectivityEvents(); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
RobustWebSocket.prototype.attachConnectivityEvents = function () { | ||
var _this = this; | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo) { | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo && this.netInfoState) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(function (state) { | ||
if (!state) { | ||
return; | ||
} | ||
// Offline -> Online | ||
var isOnline = state.isConnected && !_this.netInfoState.isConnected; | ||
@@ -239,2 +267,3 @@ if (isOnline && _this.reconnectWhenOnlineAgain) { | ||
} | ||
// Online -> Offline | ||
var isOffline = !state.isConnected && _this.netInfoState.isConnected; | ||
@@ -247,2 +276,3 @@ if (isOffline) { | ||
} | ||
// Update to latest | ||
_this.netInfoState = state; | ||
@@ -249,0 +279,0 @@ }); |
/** | ||
* proton-link-session-manager v0.2.625 | ||
* proton-link-session-manager v0.2.626 | ||
* https://github.com/greymass/proton-link-session-manager | ||
@@ -170,3 +170,3 @@ * | ||
console.log(10); | ||
this.attachConnectivityEvents(); | ||
this.initializeConnectivity(); | ||
} | ||
@@ -185,5 +185,20 @@ } | ||
} | ||
async initializeConnectivity() { | ||
if (!this.opts.netInfo) { | ||
return; | ||
} | ||
if (!this.netInfoState) { | ||
this.netInfoState = await this.opts.netInfo.fetch(); | ||
} | ||
if (this.netInfoState) { | ||
this.attachConnectivityEvents(); | ||
} | ||
} | ||
attachConnectivityEvents() { | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(state => { | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo && this.netInfoState) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener((state) => { | ||
if (!state) { | ||
return; | ||
} | ||
// Offline -> Online | ||
const isOnline = state.isConnected && !this.netInfoState.isConnected; | ||
@@ -194,2 +209,3 @@ if (isOnline && this.reconnectWhenOnlineAgain) { | ||
} | ||
// Online -> Offline | ||
const isOffline = !state.isConnected && this.netInfoState.isConnected; | ||
@@ -202,2 +218,3 @@ if (isOffline) { | ||
} | ||
// Update to latest | ||
this.netInfoState = state; | ||
@@ -204,0 +221,0 @@ }); |
{ | ||
"name": "@bloks/link-session-manager", | ||
"description": "Session management for signature providers when receiving requests using the Anchor Link protocol", | ||
"version": "0.2.625", | ||
"version": "0.2.626", | ||
"homepage": "https://github.com/greymass/proton-link-session-manager", | ||
@@ -6,0 +6,0 @@ "license": "BSD-3-Clause", |
@@ -12,3 +12,2 @@ export default class RobustWebSocket { | ||
netInfo?: any | ||
netInfoState?: any | ||
@@ -126,3 +125,3 @@ unsubscribeNetInfo?: any | ||
console.log(10) | ||
this.attachConnectivityEvents() | ||
this.initializeConnectivity() | ||
} | ||
@@ -144,5 +143,24 @@ } | ||
async initializeConnectivity() { | ||
if (!this.opts.netInfo) { | ||
return | ||
} | ||
if (!this.netInfoState) { | ||
this.netInfoState = await this.opts.netInfo.fetch() | ||
} | ||
if (this.netInfoState) { | ||
this.attachConnectivityEvents() | ||
} | ||
} | ||
attachConnectivityEvents() { | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(state => { | ||
if (!this.unsubscribeNetInfo && this.opts.netInfo && this.netInfoState) { | ||
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener((state) => { | ||
if (!state) { | ||
return | ||
} | ||
// Offline -> Online | ||
const isOnline = state.isConnected && !this.netInfoState.isConnected | ||
@@ -154,2 +172,3 @@ if (isOnline && this.reconnectWhenOnlineAgain) { | ||
// Online -> Offline | ||
const isOffline = !state.isConnected && this.netInfoState.isConnected | ||
@@ -163,2 +182,3 @@ if (isOffline) { | ||
// Update to latest | ||
this.netInfoState = state | ||
@@ -165,0 +185,0 @@ }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
103926
1788