core-3nweb-client-lib 0.42.6 → 0.42.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2017, 2020 - 2021, 2024 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2017, 2020 - 2021, 2024 - 2025 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -223,7 +223,8 @@ function getRecordAtStartOf(txt) {
|
|
|
223
223
|
const DNS_ERR_CODE = {
|
|
224
224
|
NODATA: 'ENODATA',
|
|
225
225
|
NOTFOUND: 'ENOTFOUND',
|
|
226
|
-
ESERVFAIL: 'ESERVFAIL'
|
|
226
|
+
ESERVFAIL: 'ESERVFAIL',
|
|
227
|
+
ECONNREFUSED: 'ECONNREFUSED'
|
|
227
228
|
};
|
|
228
229
|
Object.freeze(DNS_ERR_CODE);
|
|
229
230
|
function makeServiceLocator(resolver) {
|
|
@@ -243,7 +244,7 @@ function makeServiceLocator(resolver) {
|
|
|
243
244
|
if (code === DNS_ERR_CODE.NODATA) {
|
|
244
245
|
throw noServiceRecordExc(address);
|
|
245
246
|
}
|
|
246
|
-
else if (code === DNS_ERR_CODE.ESERVFAIL) {
|
|
247
|
+
else if ((code === DNS_ERR_CODE.ESERVFAIL) || (code === DNS_ERR_CODE.ECONNREFUSED)) {
|
|
247
248
|
throw noConnectionExc({ code, hostname, message });
|
|
248
249
|
}
|
|
249
250
|
else if (hostname) {
|
|
@@ -9,6 +9,7 @@ export interface WSException extends web3n.RuntimeException {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function makeWSException(params: Partial<WSException>, flags?: Partial<WSException>): WSException;
|
|
11
11
|
export interface ConnectionStatus {
|
|
12
|
+
url: string;
|
|
12
13
|
/**
|
|
13
14
|
* ping number is a number of millisecond between previous and current data receiving from server.
|
|
14
15
|
*/
|
|
@@ -36,7 +36,7 @@ const MAX_TXT_BUFFER = 64 * 1024;
|
|
|
36
36
|
*/
|
|
37
37
|
function makeJsonCommPoint(ws) {
|
|
38
38
|
const observers = new generic_ipc_1.MultiObserverWrap();
|
|
39
|
-
const { heartbeat, healthyBeat, otherBeat } = makeHeartbeat();
|
|
39
|
+
const { heartbeat, healthyBeat, otherBeat } = makeHeartbeat(ws.url);
|
|
40
40
|
ws.on('message', data => {
|
|
41
41
|
if (typeof data !== 'string') {
|
|
42
42
|
return;
|
|
@@ -59,7 +59,7 @@ function makeJsonCommPoint(ws) {
|
|
|
59
59
|
});
|
|
60
60
|
ws.on('close', (code, reason) => {
|
|
61
61
|
if (code === 1000) {
|
|
62
|
-
otherBeat(
|
|
62
|
+
otherBeat({ socketClosed: true }, true);
|
|
63
63
|
observers.complete();
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
@@ -91,24 +91,23 @@ function makeJsonCommPoint(ws) {
|
|
|
91
91
|
};
|
|
92
92
|
return { comm, heartbeat };
|
|
93
93
|
}
|
|
94
|
-
function makeHeartbeat() {
|
|
94
|
+
function makeHeartbeat(url) {
|
|
95
95
|
const status = new rxjs_1.Subject();
|
|
96
96
|
let lastInfo = Date.now();
|
|
97
97
|
function healthyBeat() {
|
|
98
98
|
const now = Date.now();
|
|
99
99
|
status.next({
|
|
100
|
+
url,
|
|
100
101
|
ping: now - lastInfo
|
|
101
102
|
});
|
|
102
103
|
lastInfo = now;
|
|
103
104
|
}
|
|
104
|
-
function otherBeat(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
function otherBeat(params, end = false) {
|
|
106
|
+
status.next({
|
|
107
|
+
url,
|
|
108
|
+
...params
|
|
109
|
+
});
|
|
108
110
|
if (end) {
|
|
109
|
-
status.next({
|
|
110
|
-
socketClosed: true
|
|
111
|
-
});
|
|
112
111
|
status.complete();
|
|
113
112
|
}
|
|
114
113
|
}
|