iosignal 1.6.1 → 1.7.1
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/README.md +254 -247
- package/auth_file.json +13 -13
- package/auth_file.mjs +23 -23
- package/dist/iosignal.cjs +2 -2
- package/dist/iosignal.esm.js.map +1 -1
- package/dist/iosignal.min.js.map +1 -1
- package/index.js +19 -19
- package/indexWebBrowser.js +13 -13
- package/package.json +60 -59
- package/rollup.config.js +69 -69
- package/src/api/RedisAPI.js +65 -68
- package/src/api/api_constant.js +7 -7
- package/src/api/api_reply.js +31 -34
- package/src/api/api_sudo.js +91 -96
- package/src/auth/Auth_Env.js +76 -78
- package/src/auth/Auth_File.js +71 -75
- package/src/auth/Auth_Redis.js +44 -50
- package/src/auth/BohoAuth.js +164 -168
- package/src/client/CongPacket.js +141 -150
- package/src/client/IOCongSocket.js +81 -88
- package/src/client/IOCore.js +822 -851
- package/src/client/IOWS.js +80 -81
- package/src/client/IOWebSocket.js +111 -112
- package/src/common/constants.js +148 -159
- package/src/common/payload.js +81 -82
- package/src/common/quotaTable.js +68 -68
- package/src/common/util.js +61 -61
- package/src/server/FileLogger.js +30 -30
- package/src/server/Manager.js +433 -449
- package/src/server/Metric.js +155 -154
- package/src/server/Remote.js +207 -0
- package/src/server/{ServerRemoteCore.js → RemoteCore.js} +439 -467
- package/src/server/Server.js +163 -166
- package/src/server/serverOption.js +56 -56
- package/test-browser/favicon.ico +0 -0
- package/test-browser/index.html +96 -93
- package/test-browser/server.js +11 -11
- package/test-client-nodejs/client.cjs +17 -17
- package/test-client-nodejs/client.mjs +17 -17
- package/test-client-nodejs/client_api_reply.mjs +15 -15
- package/test-client-nodejs/stateChange.mjs +19 -19
- package/test-server/server-Auth_Env.js +19 -19
- package/test-server/server-Auth_File.js +12 -12
- package/test-server/server-api_reply.js +6 -6
- package/test-server/server-api_sudo.js +7 -7
- package/test-server/server-commonjs.cjs +8 -8
- package/test-server/server-esm.mjs +20 -19
- package/test-server/simple-server.mjs +11 -11
- package/test-signal-payloadType/signalPack.js +34 -34
- package/test-signal-payloadType/signaling.js +60 -60
- package/src/server/ServerRemote.js +0 -227
package/src/client/IOWS.js
CHANGED
|
@@ -1,81 +1,80 @@
|
|
|
1
|
-
import { IOCore } from "./IOCore.js";
|
|
2
|
-
import { WebSocket } from "ws";
|
|
3
|
-
|
|
4
|
-
// Node.js 'ws' websocket
|
|
5
|
-
export class IOWS extends IOCore{
|
|
6
|
-
constructor(url
|
|
7
|
-
super(url);
|
|
8
|
-
if(url) this.open();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
close() {
|
|
14
|
-
if(this.socket
|
|
15
|
-
this.socket.onclose = null
|
|
16
|
-
this.socket.onmessage = null
|
|
17
|
-
this.socket.onerror = null
|
|
18
|
-
this.socket.close();
|
|
19
|
-
this.socket = null;
|
|
20
|
-
}
|
|
21
|
-
this.emit('close')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
stop() {
|
|
27
|
-
this.close()
|
|
28
|
-
clearInterval(this.connectionCheckerIntervalID);
|
|
29
|
-
this.connectionCheckerIntervalID = null
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
keepAlive() {
|
|
33
|
-
if (
|
|
34
|
-
this.open();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
createConnection(url){
|
|
40
|
-
// node WebSocket
|
|
41
|
-
this.socket = new WebSocket
|
|
42
|
-
this.stateChange('opening')
|
|
43
|
-
|
|
44
|
-
this.socket.onopen = () => {
|
|
45
|
-
this.socket.on('message', this.onWebSocketMessage.bind(this)
|
|
46
|
-
this.emit('open'
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
this.socket.onerror = (e)=>{
|
|
50
|
-
this.emit('error', e)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.socket.onclose = ()=>{
|
|
54
|
-
this.emit('close'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
onWebSocketMessage(
|
|
59
|
-
this.rxCounter++;
|
|
60
|
-
this.lastTxRxTime = Date.now();
|
|
61
|
-
this.rxBytes += data.byteLength
|
|
62
|
-
this.emit('socket_data', data
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
socket_send(data) {
|
|
66
|
-
if(
|
|
67
|
-
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import { IOCore } from "./IOCore.js";
|
|
2
|
+
import { WebSocket } from "ws";
|
|
3
|
+
|
|
4
|
+
// Node.js 'ws' websocket
|
|
5
|
+
export class IOWS extends IOCore {
|
|
6
|
+
constructor(url) {
|
|
7
|
+
super(url);
|
|
8
|
+
if (url) this.open();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
close() {
|
|
14
|
+
if (this.socket) {
|
|
15
|
+
this.socket.onclose = null
|
|
16
|
+
this.socket.onmessage = null
|
|
17
|
+
this.socket.onerror = null
|
|
18
|
+
this.socket.close();
|
|
19
|
+
this.socket = null;
|
|
20
|
+
}
|
|
21
|
+
this.emit('close')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
stop() {
|
|
27
|
+
this.close()
|
|
28
|
+
clearInterval(this.connectionCheckerIntervalID);
|
|
29
|
+
this.connectionCheckerIntervalID = null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
keepAlive() {
|
|
33
|
+
if (!this.socket || this.socket?.readyState === 3) {
|
|
34
|
+
this.open();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
createConnection(url) {
|
|
40
|
+
// node WebSocket
|
|
41
|
+
this.socket = new WebSocket(url);
|
|
42
|
+
this.stateChange('opening')
|
|
43
|
+
|
|
44
|
+
this.socket.onopen = () => {
|
|
45
|
+
this.socket.on('message', this.onWebSocketMessage.bind(this));
|
|
46
|
+
this.emit('open');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
this.socket.onerror = (e) => {
|
|
50
|
+
this.emit('error', e)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.socket.onclose = () => {
|
|
54
|
+
this.emit('close');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
onWebSocketMessage(data) {
|
|
59
|
+
this.rxCounter++;
|
|
60
|
+
this.lastTxRxTime = Date.now();
|
|
61
|
+
this.rxBytes += data.byteLength
|
|
62
|
+
this.emit('socket_data', data);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
socket_send(data) {
|
|
66
|
+
if (this.socket?.readyState === 1) {
|
|
67
|
+
this.socket.send(data)
|
|
68
|
+
this.txCounter++;
|
|
69
|
+
this.txBytes += data.byteLength
|
|
70
|
+
this.lastTxRxTime = Date.now();
|
|
71
|
+
} else {
|
|
72
|
+
console.log('.')
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
@@ -1,112 +1,111 @@
|
|
|
1
|
-
import { IOCore } from "./IOCore.js";
|
|
2
|
-
import { Buffer } from 'meta-buffer-pack'
|
|
3
|
-
export { Boho, RAND, BohoMsg, Meta, MetaSize, sha256, MBP, Buffer } from 'boho'
|
|
4
|
-
export * from '../common/constants.js'
|
|
5
|
-
|
|
6
|
-
// Browser WebSocket
|
|
7
|
-
export class IO extends IOCore {
|
|
8
|
-
static binaryType = "arraybuffer"
|
|
9
|
-
|
|
10
|
-
constructor(url) {
|
|
11
|
-
super(url);
|
|
12
|
-
document.addEventListener('visibilitychange', this.browserVisiblePing.bind(this));
|
|
13
|
-
if (url) this.open();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
browserVisiblePing() {
|
|
17
|
-
if (document.visibilityState === 'visible') {
|
|
18
|
-
this.ping()
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
close() {
|
|
24
|
-
if (this.socket) {
|
|
25
|
-
this.socket.onclose = null
|
|
26
|
-
this.socket.onmessage = null
|
|
27
|
-
this.socket.onerror = null
|
|
28
|
-
this.socket.close();
|
|
29
|
-
this.socket = null;
|
|
30
|
-
}
|
|
31
|
-
this.emit('close')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
stop() {
|
|
36
|
-
this.close()
|
|
37
|
-
clearInterval(this.connectionCheckerIntervalID);
|
|
38
|
-
this.connectionCheckerIntervalID = null
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
keepAlive() {
|
|
43
|
-
if (!this.socket || this.socket?.readyState === 3) {
|
|
44
|
-
this.open();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
createConnection(url) {
|
|
51
|
-
// Web Browser WebSocket
|
|
52
|
-
this.socket = new WebSocket(url);
|
|
53
|
-
this.socket.binaryType = IO.binaryType
|
|
54
|
-
|
|
55
|
-
this.stateChange('opening')
|
|
56
|
-
|
|
57
|
-
this.socket.onopen = () => {
|
|
58
|
-
if (this.socket.binaryType == "arraybuffer") {
|
|
59
|
-
this.socket.onmessage = this.onWebSocketMessage.bind(this);
|
|
60
|
-
} else { // blob
|
|
61
|
-
this.socket.onmessage = this.onWebSocketMessageBlob.bind(this);
|
|
62
|
-
}
|
|
63
|
-
this.emit('open');
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
this.socket.onerror = (e) => {
|
|
67
|
-
this.emit('error', e)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
this.socket.onclose = () => {
|
|
71
|
-
this.emit('close');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
onWebSocketMessage(event) {
|
|
76
|
-
// event.data is arrayBuffer or text_message
|
|
77
|
-
this.rxCounter++;
|
|
78
|
-
this.lastTxRxTime = Date.now();
|
|
79
|
-
let buffer = Buffer.from(event.data)
|
|
80
|
-
this.rxBytes += buffer.byteLength
|
|
81
|
-
this.emit('socket_data', buffer);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async onWebSocketMessageBlob(event) {
|
|
85
|
-
// event.data is Blob or text_message
|
|
86
|
-
this.rxCounter++;
|
|
87
|
-
this.lastTxRxTime = Date.now();
|
|
88
|
-
let buffer;
|
|
89
|
-
if(
|
|
90
|
-
let ab = await event.data.arrayBuffer()
|
|
91
|
-
buffer = Buffer.from(ab)
|
|
92
|
-
}else{
|
|
93
|
-
buffer = Buffer.from(event.data)
|
|
94
|
-
}
|
|
95
|
-
this.rxBytes += buffer.byteLength
|
|
96
|
-
this.emit('socket_data', buffer);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
socket_send(data) {
|
|
100
|
-
if (this.socket?.readyState === 1) {
|
|
101
|
-
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
import { IOCore } from "./IOCore.js";
|
|
2
|
+
import { Buffer } from 'meta-buffer-pack'
|
|
3
|
+
export { Boho, RAND, BohoMsg, Meta, MetaSize, sha256, MBP, Buffer } from 'boho'
|
|
4
|
+
export * from '../common/constants.js'
|
|
5
|
+
|
|
6
|
+
// Browser WebSocket
|
|
7
|
+
export class IO extends IOCore {
|
|
8
|
+
static binaryType = "arraybuffer"
|
|
9
|
+
|
|
10
|
+
constructor(url) {
|
|
11
|
+
super(url);
|
|
12
|
+
document.addEventListener('visibilitychange', this.browserVisiblePing.bind(this));
|
|
13
|
+
if (url) this.open();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
browserVisiblePing() {
|
|
17
|
+
if (document.visibilityState === 'visible') {
|
|
18
|
+
this.ping()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
close() {
|
|
24
|
+
if (this.socket) {
|
|
25
|
+
this.socket.onclose = null
|
|
26
|
+
this.socket.onmessage = null
|
|
27
|
+
this.socket.onerror = null
|
|
28
|
+
this.socket.close();
|
|
29
|
+
this.socket = null;
|
|
30
|
+
}
|
|
31
|
+
this.emit('close')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
stop() {
|
|
36
|
+
this.close()
|
|
37
|
+
clearInterval(this.connectionCheckerIntervalID);
|
|
38
|
+
this.connectionCheckerIntervalID = null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
keepAlive() {
|
|
43
|
+
if (!this.socket || this.socket?.readyState === 3) {
|
|
44
|
+
this.open();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
createConnection(url) {
|
|
51
|
+
// Web Browser WebSocket
|
|
52
|
+
this.socket = new WebSocket(url);
|
|
53
|
+
this.socket.binaryType = IO.binaryType
|
|
54
|
+
|
|
55
|
+
this.stateChange('opening')
|
|
56
|
+
|
|
57
|
+
this.socket.onopen = () => {
|
|
58
|
+
if (this.socket.binaryType == "arraybuffer") {
|
|
59
|
+
this.socket.onmessage = this.onWebSocketMessage.bind(this);
|
|
60
|
+
} else { // blob
|
|
61
|
+
this.socket.onmessage = this.onWebSocketMessageBlob.bind(this);
|
|
62
|
+
}
|
|
63
|
+
this.emit('open');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
this.socket.onerror = (e) => {
|
|
67
|
+
this.emit('error', e)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.socket.onclose = () => {
|
|
71
|
+
this.emit('close');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
onWebSocketMessage(event) {
|
|
76
|
+
// event.data is arrayBuffer or text_message
|
|
77
|
+
this.rxCounter++;
|
|
78
|
+
this.lastTxRxTime = Date.now();
|
|
79
|
+
let buffer = Buffer.from(event.data)
|
|
80
|
+
this.rxBytes += buffer.byteLength
|
|
81
|
+
this.emit('socket_data', buffer);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async onWebSocketMessageBlob(event) {
|
|
85
|
+
// event.data is Blob or text_message
|
|
86
|
+
this.rxCounter++;
|
|
87
|
+
this.lastTxRxTime = Date.now();
|
|
88
|
+
let buffer;
|
|
89
|
+
if (event.data instanceof Blob) {
|
|
90
|
+
let ab = await event.data.arrayBuffer()
|
|
91
|
+
buffer = Buffer.from(ab)
|
|
92
|
+
} else {
|
|
93
|
+
buffer = Buffer.from(event.data)
|
|
94
|
+
}
|
|
95
|
+
this.rxBytes += buffer.byteLength
|
|
96
|
+
this.emit('socket_data', buffer);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
socket_send(data) {
|
|
100
|
+
if (this.socket?.readyState === 1) {
|
|
101
|
+
this.socket.send(data)
|
|
102
|
+
this.txCounter++;
|
|
103
|
+
this.txBytes += data.byteLength
|
|
104
|
+
this.lastTxRxTime = Date.now();
|
|
105
|
+
} else {
|
|
106
|
+
console.log('.')
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|