iosignal 4.5.0 → 4.6.0
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.
- package/dist/io.d.ts +7 -2
- package/dist/io.js +3 -3
- package/dist/io.js.map +1 -1
- package/dist/io.min.js +3 -3
- package/dist/io.min.js.map +1 -1
- package/dist/iosignal.js +21 -17
- package/dist/types/client/IOCore.d.ts +3 -2
- package/dist/types/client/browser/IOWebSocket.d.ts +4 -0
- package/dist/types/common/constants.d.ts +2 -0
- package/package.json +1 -1
- package/src/client/IOCongSocket.js +2 -4
- package/src/client/IOCore.js +7 -5
- package/src/client/IOWS.js +4 -5
- package/src/client/browser/IOWebSocket.js +1 -3
- package/src/common/constants.js +3 -1
- package/src/server/RemoteCore.js +6 -3
package/dist/iosignal.js
CHANGED
|
@@ -13,7 +13,7 @@ import require$$2, { networkInterfaces } from 'os';
|
|
|
13
13
|
import require$$0$1 from 'buffer';
|
|
14
14
|
import { memoryUsage } from 'process';
|
|
15
15
|
|
|
16
|
-
var version$1 = "4.
|
|
16
|
+
var version$1 = "4.6.0";
|
|
17
17
|
var pkg = {
|
|
18
18
|
version: version$1};
|
|
19
19
|
|
|
@@ -437,6 +437,7 @@ for (let c in ENC_MODE) { ENC_MODE[ENC_MODE[c]] = c; }
|
|
|
437
437
|
* @property {number} TAG_LEN1
|
|
438
438
|
* @property {number} TAG_LEN2
|
|
439
439
|
* @property {number} CONNECTION_CHECKER_PERIOD
|
|
440
|
+
* @property {number} CLIENT_PING_PERIOD
|
|
440
441
|
* @property {number} PROMISE_TIMEOUT
|
|
441
442
|
* @property {number} DID
|
|
442
443
|
* @property {number} CID
|
|
@@ -444,7 +445,8 @@ for (let c in ENC_MODE) { ENC_MODE[ENC_MODE[c]] = c; }
|
|
|
444
445
|
const SIZE_LIMIT = {
|
|
445
446
|
TAG_LEN1: 255,
|
|
446
447
|
TAG_LEN2: 65535,
|
|
447
|
-
CONNECTION_CHECKER_PERIOD:
|
|
448
|
+
CONNECTION_CHECKER_PERIOD: 3000,
|
|
449
|
+
CLIENT_PING_PERIOD: 40000,
|
|
448
450
|
PROMISE_TIMEOUT: 5000,
|
|
449
451
|
DID: 8,
|
|
450
452
|
CID: 12
|
|
@@ -1030,13 +1032,15 @@ class IOCore extends EventEmitter {
|
|
|
1030
1032
|
}
|
|
1031
1033
|
|
|
1032
1034
|
/**
|
|
1033
|
-
* The core keep-alive logic.
|
|
1034
|
-
* The
|
|
1035
|
+
* The core keep-alive logic.
|
|
1036
|
+
* The specific logic for checking the socket's state and reconnecting
|
|
1037
|
+
* is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
|
|
1035
1038
|
*/
|
|
1036
1039
|
keepAlive() {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
+
this.keepConnection();
|
|
1041
|
+
if( Date.now() - this.lastTxRxTime > SIZE_LIMIT.CLIENT_PING_PERIOD ){
|
|
1042
|
+
this.ping();
|
|
1043
|
+
}
|
|
1040
1044
|
}
|
|
1041
1045
|
|
|
1042
1046
|
/**
|
|
@@ -2146,13 +2150,11 @@ class IOCongSocket extends IOCore {
|
|
|
2146
2150
|
|
|
2147
2151
|
|
|
2148
2152
|
|
|
2149
|
-
|
|
2153
|
+
keepConnection() {
|
|
2150
2154
|
if (!this.autoReconnect) return;
|
|
2151
2155
|
// Reconnect only if the socket is fully destroyed and the state is closed.
|
|
2152
2156
|
if ((!this.socket || this.socket.destroyed)) {
|
|
2153
2157
|
this.open();
|
|
2154
|
-
}else {
|
|
2155
|
-
this.ping();
|
|
2156
2158
|
}
|
|
2157
2159
|
}
|
|
2158
2160
|
|
|
@@ -7574,17 +7576,16 @@ class IOWS extends IOCore {
|
|
|
7574
7576
|
super.close();
|
|
7575
7577
|
}
|
|
7576
7578
|
|
|
7577
|
-
|
|
7578
|
-
keepAlive() {
|
|
7579
|
+
keepConnection() {
|
|
7579
7580
|
if (!this.autoReconnect) return;
|
|
7580
7581
|
// Reconnect only if the socket is closed and the state reflects that.
|
|
7581
7582
|
if ((!this.socket || this.socket.readyState === WebSocket.CLOSED) ) {
|
|
7582
7583
|
this.open();
|
|
7583
|
-
}else {
|
|
7584
|
-
this.ping();
|
|
7585
7584
|
}
|
|
7586
7585
|
}
|
|
7587
7586
|
|
|
7587
|
+
|
|
7588
|
+
|
|
7588
7589
|
createConnection(url) {
|
|
7589
7590
|
// node WebSocket
|
|
7590
7591
|
this.socket = new WebSocket(url);
|
|
@@ -7723,9 +7724,12 @@ class RemoteCore {
|
|
|
7723
7724
|
setState(state) {
|
|
7724
7725
|
this.state = state;
|
|
7725
7726
|
if (serverOption.debug.showAuthInfo) {
|
|
7726
|
-
state
|
|
7727
|
-
|
|
7728
|
-
|
|
7727
|
+
this.stateLog.push( state + ":" + STATE[ state] );
|
|
7728
|
+
if( state == STATE.AUTH_ACK){
|
|
7729
|
+
console.log('[auth success]', this.cid, this.stateLog.join('>'));
|
|
7730
|
+
}else if( state == STATE.AUTH_FAIL){
|
|
7731
|
+
console.log('[auth_fail]',this.stateLog.join('>'));
|
|
7732
|
+
}
|
|
7729
7733
|
}
|
|
7730
7734
|
}
|
|
7731
7735
|
|
|
@@ -167,8 +167,9 @@ export class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
167
167
|
*/
|
|
168
168
|
destroy(): void;
|
|
169
169
|
/**
|
|
170
|
-
* The core keep-alive logic.
|
|
171
|
-
* The
|
|
170
|
+
* The core keep-alive logic.
|
|
171
|
+
* The specific logic for checking the socket's state and reconnecting
|
|
172
|
+
* is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
|
|
172
173
|
*/
|
|
173
174
|
keepAlive(): void;
|
|
174
175
|
/**
|
|
@@ -48,6 +48,10 @@ export default class IO extends IOCore {
|
|
|
48
48
|
* Pings the server when the browser tab becomes visible.
|
|
49
49
|
*/
|
|
50
50
|
browserVisiblePing(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Keeps the connection alive by re-connecting if closed.
|
|
53
|
+
*/
|
|
54
|
+
keepConnection(): void;
|
|
51
55
|
/**
|
|
52
56
|
* Creates a new WebSocket connection.
|
|
53
57
|
* @param {string} url - The WebSocket URL to connect to.
|
|
@@ -43,6 +43,7 @@ export type SIZE_LIMIT = {
|
|
|
43
43
|
TAG_LEN1: number;
|
|
44
44
|
TAG_LEN2: number;
|
|
45
45
|
CONNECTION_CHECKER_PERIOD: number;
|
|
46
|
+
CLIENT_PING_PERIOD: number;
|
|
46
47
|
PROMISE_TIMEOUT: number;
|
|
47
48
|
DID: number;
|
|
48
49
|
CID: number;
|
|
@@ -51,6 +52,7 @@ export namespace SIZE_LIMIT {
|
|
|
51
52
|
let TAG_LEN1: number;
|
|
52
53
|
let TAG_LEN2: number;
|
|
53
54
|
let CONNECTION_CHECKER_PERIOD: number;
|
|
55
|
+
let CLIENT_PING_PERIOD: number;
|
|
54
56
|
let PROMISE_TIMEOUT: number;
|
|
55
57
|
let DID: number;
|
|
56
58
|
let CID: number;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IOCore } from "./IOCore.js"
|
|
2
|
-
import {
|
|
2
|
+
import { SIZE_LIMIT } from "../common/constants.js";
|
|
3
3
|
import { pack, CongRx } from './CongPacket.js'
|
|
4
4
|
import net from 'net'
|
|
5
5
|
|
|
@@ -30,13 +30,11 @@ export class IOCongSocket extends IOCore {
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
keepConnection() {
|
|
34
34
|
if (!this.autoReconnect) return;
|
|
35
35
|
// Reconnect only if the socket is fully destroyed and the state is closed.
|
|
36
36
|
if ((!this.socket || this.socket.destroyed)) {
|
|
37
37
|
this.open();
|
|
38
|
-
}else{
|
|
39
|
-
this.ping();
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
|
package/src/client/IOCore.js
CHANGED
|
@@ -265,13 +265,15 @@ export class IOCore extends EventEmitter {
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
/**
|
|
268
|
-
* The core keep-alive logic.
|
|
269
|
-
* The
|
|
268
|
+
* The core keep-alive logic.
|
|
269
|
+
* The specific logic for checking the socket's state and reconnecting
|
|
270
|
+
* is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
|
|
270
271
|
*/
|
|
271
272
|
keepAlive() {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
this.keepConnection();
|
|
274
|
+
if( Date.now() - this.lastTxRxTime > SIZE_LIMIT.CLIENT_PING_PERIOD ){
|
|
275
|
+
this.ping();
|
|
276
|
+
}
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
/**
|
package/src/client/IOWS.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IOCore } from "./IOCore.js";
|
|
2
|
-
import {
|
|
2
|
+
import { SIZE_LIMIT } from "../common/constants.js";
|
|
3
3
|
import { WebSocket } from "ws";
|
|
4
4
|
|
|
5
5
|
// Node.js 'ws' websocket
|
|
@@ -24,17 +24,16 @@ export class IOWS extends IOCore {
|
|
|
24
24
|
super.close();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
keepAlive() {
|
|
27
|
+
keepConnection() {
|
|
29
28
|
if (!this.autoReconnect) return;
|
|
30
29
|
// Reconnect only if the socket is closed and the state reflects that.
|
|
31
30
|
if ((!this.socket || this.socket.readyState === WebSocket.CLOSED) ) {
|
|
32
31
|
this.open();
|
|
33
|
-
}else{
|
|
34
|
-
this.ping();
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
|
|
35
|
+
|
|
36
|
+
|
|
38
37
|
createConnection(url) {
|
|
39
38
|
// node WebSocket
|
|
40
39
|
this.socket = new WebSocket(url);
|
|
@@ -106,13 +106,11 @@ export default class IO extends IOCore {
|
|
|
106
106
|
/**
|
|
107
107
|
* Keeps the connection alive by re-connecting if closed.
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
keepConnection() {
|
|
110
110
|
if (!this.autoReconnect) return;
|
|
111
111
|
// Reconnect only if the socket is closed and the state reflects that.
|
|
112
112
|
if ((!this.socket || this.socket.readyState === WebSocket.CLOSED) ) {
|
|
113
113
|
this.open();
|
|
114
|
-
}else{
|
|
115
|
-
this.ping();
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
|
package/src/common/constants.js
CHANGED
|
@@ -56,6 +56,7 @@ for (let c in ENC_MODE) { ENC_MODE[ENC_MODE[c]] = c }
|
|
|
56
56
|
* @property {number} TAG_LEN1
|
|
57
57
|
* @property {number} TAG_LEN2
|
|
58
58
|
* @property {number} CONNECTION_CHECKER_PERIOD
|
|
59
|
+
* @property {number} CLIENT_PING_PERIOD
|
|
59
60
|
* @property {number} PROMISE_TIMEOUT
|
|
60
61
|
* @property {number} DID
|
|
61
62
|
* @property {number} CID
|
|
@@ -63,7 +64,8 @@ for (let c in ENC_MODE) { ENC_MODE[ENC_MODE[c]] = c }
|
|
|
63
64
|
export const SIZE_LIMIT = {
|
|
64
65
|
TAG_LEN1: 255,
|
|
65
66
|
TAG_LEN2: 65535,
|
|
66
|
-
CONNECTION_CHECKER_PERIOD:
|
|
67
|
+
CONNECTION_CHECKER_PERIOD: 3000,
|
|
68
|
+
CLIENT_PING_PERIOD: 40000,
|
|
67
69
|
PROMISE_TIMEOUT: 5000,
|
|
68
70
|
DID: 8,
|
|
69
71
|
CID: 12
|
package/src/server/RemoteCore.js
CHANGED
|
@@ -49,9 +49,12 @@ export class RemoteCore {
|
|
|
49
49
|
setState(state) {
|
|
50
50
|
this.state = state
|
|
51
51
|
if (serverOption.debug.showAuthInfo) {
|
|
52
|
-
state
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
this.stateLog.push( state + ":" + STATE[ state] )
|
|
53
|
+
if( state == STATE.AUTH_ACK){
|
|
54
|
+
console.log('[auth success]', this.cid, this.stateLog.join('>'))
|
|
55
|
+
}else if( state == STATE.AUTH_FAIL){
|
|
56
|
+
console.log('[auth_fail]',this.stateLog.join('>'))
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
|