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.
Files changed (51) hide show
  1. package/README.md +254 -247
  2. package/auth_file.json +13 -13
  3. package/auth_file.mjs +23 -23
  4. package/dist/iosignal.cjs +2 -2
  5. package/dist/iosignal.esm.js.map +1 -1
  6. package/dist/iosignal.min.js.map +1 -1
  7. package/index.js +19 -19
  8. package/indexWebBrowser.js +13 -13
  9. package/package.json +60 -59
  10. package/rollup.config.js +69 -69
  11. package/src/api/RedisAPI.js +65 -68
  12. package/src/api/api_constant.js +7 -7
  13. package/src/api/api_reply.js +31 -34
  14. package/src/api/api_sudo.js +91 -96
  15. package/src/auth/Auth_Env.js +76 -78
  16. package/src/auth/Auth_File.js +71 -75
  17. package/src/auth/Auth_Redis.js +44 -50
  18. package/src/auth/BohoAuth.js +164 -168
  19. package/src/client/CongPacket.js +141 -150
  20. package/src/client/IOCongSocket.js +81 -88
  21. package/src/client/IOCore.js +822 -851
  22. package/src/client/IOWS.js +80 -81
  23. package/src/client/IOWebSocket.js +111 -112
  24. package/src/common/constants.js +148 -159
  25. package/src/common/payload.js +81 -82
  26. package/src/common/quotaTable.js +68 -68
  27. package/src/common/util.js +61 -61
  28. package/src/server/FileLogger.js +30 -30
  29. package/src/server/Manager.js +433 -449
  30. package/src/server/Metric.js +155 -154
  31. package/src/server/Remote.js +207 -0
  32. package/src/server/{ServerRemoteCore.js → RemoteCore.js} +439 -467
  33. package/src/server/Server.js +163 -166
  34. package/src/server/serverOption.js +56 -56
  35. package/test-browser/favicon.ico +0 -0
  36. package/test-browser/index.html +96 -93
  37. package/test-browser/server.js +11 -11
  38. package/test-client-nodejs/client.cjs +17 -17
  39. package/test-client-nodejs/client.mjs +17 -17
  40. package/test-client-nodejs/client_api_reply.mjs +15 -15
  41. package/test-client-nodejs/stateChange.mjs +19 -19
  42. package/test-server/server-Auth_Env.js +19 -19
  43. package/test-server/server-Auth_File.js +12 -12
  44. package/test-server/server-api_reply.js +6 -6
  45. package/test-server/server-api_sudo.js +7 -7
  46. package/test-server/server-commonjs.cjs +8 -8
  47. package/test-server/server-esm.mjs +20 -19
  48. package/test-server/simple-server.mjs +11 -11
  49. package/test-signal-payloadType/signalPack.js +34 -34
  50. package/test-signal-payloadType/signaling.js +60 -60
  51. package/src/server/ServerRemote.js +0 -227
@@ -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 ( !this.socket || this.socket?.readyState === 3 ) { //closed
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 ){ //open
67
- // console.log('websocket send', data)
68
- this.socket.send( data )
69
- this.txCounter++;
70
- this.txBytes += data.byteLength
71
- this.lastTxRxTime = Date.now();
72
- }else{
73
- console.log('')
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) { //closed
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) { //open
101
- // console.log('websocket send', data)
102
- this.socket.send(data)
103
- this.txCounter++;
104
- this.txBytes += data.byteLength
105
- this.lastTxRxTime = Date.now();
106
- } else {
107
- console.log('.')
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
+