iosignal 1.4.2 → 1.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.
Files changed (52) hide show
  1. package/README.md +247 -240
  2. package/auth_file.json +13 -13
  3. package/auth_file.mjs +23 -23
  4. package/dist/iosignal.cjs +1 -1
  5. package/dist/iosignal.esm.js +2 -2
  6. package/dist/iosignal.esm.js.map +1 -1
  7. package/dist/iosignal.min.js +2 -2
  8. package/dist/iosignal.min.js.map +1 -1
  9. package/index.js +19 -19
  10. package/indexWebBrowser.js +13 -13
  11. package/package.json +59 -60
  12. package/rollup.config.js +69 -69
  13. package/src/api/RedisAPI.js +68 -68
  14. package/src/api/api_constant.js +7 -7
  15. package/src/api/api_reply.js +34 -34
  16. package/src/api/api_sudo.js +96 -96
  17. package/src/auth/Auth_Env.js +78 -78
  18. package/src/auth/Auth_File.js +75 -75
  19. package/src/auth/Auth_Redis.js +50 -50
  20. package/src/auth/BohoAuth.js +168 -168
  21. package/src/client/CongPacket.js +150 -150
  22. package/src/client/IOCongSocket.js +88 -88
  23. package/src/client/IOCore.js +851 -851
  24. package/src/client/IOWS.js +81 -81
  25. package/src/client/IOWebSocket.js +107 -95
  26. package/src/common/constants.js +159 -159
  27. package/src/common/payload.js +82 -82
  28. package/src/common/quotaTable.js +68 -68
  29. package/src/common/util.js +61 -61
  30. package/src/server/FileLogger.js +30 -30
  31. package/src/server/Manager.js +449 -449
  32. package/src/server/Metric.js +154 -154
  33. package/src/server/Server.js +166 -148
  34. package/src/server/ServerRemote.js +227 -227
  35. package/src/server/ServerRemoteCore.js +467 -467
  36. package/src/server/serverOption.js +56 -55
  37. package/test-browser/favicon.ico +0 -0
  38. package/test-browser/index.html +92 -92
  39. package/test-browser/server.js +11 -11
  40. package/test-client-nodejs/client.cjs +17 -17
  41. package/test-client-nodejs/client.mjs +17 -17
  42. package/test-client-nodejs/client_api_reply.mjs +15 -15
  43. package/test-client-nodejs/stateChange.mjs +19 -19
  44. package/test-server/server-Auth_Env.js +19 -19
  45. package/test-server/server-Auth_File.js +12 -12
  46. package/test-server/server-api_reply.js +6 -6
  47. package/test-server/server-api_sudo.js +7 -7
  48. package/test-server/server-commonjs.cjs +8 -8
  49. package/test-server/server-esm.mjs +19 -19
  50. package/test-server/simple-server.mjs +11 -11
  51. package/test-signal-payloadType/signalPack.js +34 -34
  52. package/test-signal-payloadType/signaling.js +60 -60
@@ -1,88 +1,88 @@
1
- import { IOCore } from "./IOCore.js"
2
- import { pack, CongRx } from './CongPacket.js'
3
- import net from'net'
4
-
5
-
6
- export class IOCongSocket extends IOCore{
7
- constructor( url ) {
8
- super( url );
9
- if(url) this.open();
10
- }
11
-
12
- close() {
13
- this.socket?.end();
14
- this.socket = null;
15
- }
16
-
17
- stop() {
18
- this.close()
19
- clearInterval(this.connectionCheckerIntervalID);
20
- this.connectionCheckerIntervalID = null
21
- }
22
-
23
- keepAlive() {
24
- let state = this.socket?.readyState;
25
- if ( !this.socket || !(state === 'open' || state === 'opening') ) {
26
- this.open();
27
- }
28
- }
29
-
30
-
31
- createConnection(url){
32
- // TCP Socket
33
- let urlObj = new URL( url )
34
- // console.log(urlObj)
35
- if( urlObj.protocol != "cong:"){
36
- urlObj = new URL( 'cong://'+ url )
37
- }
38
- // console.log('congSocket url:', urlObj )
39
- this.socket = net.createConnection( urlObj.port, urlObj.hostname )
40
- this.stateChange('opening')
41
-
42
- this.socket.on('connect' , ()=>{
43
- // console.log('cong connected' )
44
- this.congRx = new CongRx();
45
- this.socket.pipe( this.congRx )
46
- this.congRx.on("data", this.onTCPSocketMessage.bind(this));
47
- this.emit('open')
48
- })
49
-
50
- this.socket.on('error', e=>{
51
- this.emit('error', e)
52
- })
53
-
54
- this.socket.on('close', ()=>{
55
- this.emit('close');
56
- })
57
-
58
- }
59
-
60
- onTCPSocketMessage( data ) {
61
- this.rxCounter++;
62
- this.rxBytes += data.byteLength
63
- this.lastTxRxTime = Date.now();
64
- // console.log('>> congRx data.len:', data.byteLength )
65
- // console.log('>> cong.rxi, rxi_zero:', this.congRx.rxi, this.congRx.rxi_zero )
66
- this.emit('socket_data', data );
67
-
68
- }
69
-
70
- socket_send(data) {
71
- if( this.socket?.readyState === 'open'){
72
- // console.log('tcp send raw payload:', data)
73
- let packData = pack(data);
74
- // console.log('tcp send cong packed:', packData)
75
- this.socket.write( packData )
76
- this.txCounter++;
77
- this.txBytes += packData.byteLength;
78
- this.lastTxRxTime = Date.now();
79
- }else{
80
- console.log('.')
81
- }
82
- }
83
-
84
- }
85
-
86
-
87
-
88
-
1
+ import { IOCore } from "./IOCore.js"
2
+ import { pack, CongRx } from './CongPacket.js'
3
+ import net from'net'
4
+
5
+
6
+ export class IOCongSocket extends IOCore{
7
+ constructor( url ) {
8
+ super( url );
9
+ if(url) this.open();
10
+ }
11
+
12
+ close() {
13
+ this.socket?.end();
14
+ this.socket = null;
15
+ }
16
+
17
+ stop() {
18
+ this.close()
19
+ clearInterval(this.connectionCheckerIntervalID);
20
+ this.connectionCheckerIntervalID = null
21
+ }
22
+
23
+ keepAlive() {
24
+ let state = this.socket?.readyState;
25
+ if ( !this.socket || !(state === 'open' || state === 'opening') ) {
26
+ this.open();
27
+ }
28
+ }
29
+
30
+
31
+ createConnection(url){
32
+ // TCP Socket
33
+ let urlObj = new URL( url )
34
+ // console.log(urlObj)
35
+ if( urlObj.protocol != "cong:"){
36
+ urlObj = new URL( 'cong://'+ url )
37
+ }
38
+ // console.log('congSocket url:', urlObj )
39
+ this.socket = net.createConnection( urlObj.port, urlObj.hostname )
40
+ this.stateChange('opening')
41
+
42
+ this.socket.on('connect' , ()=>{
43
+ // console.log('cong connected' )
44
+ this.congRx = new CongRx();
45
+ this.socket.pipe( this.congRx )
46
+ this.congRx.on("data", this.onTCPSocketMessage.bind(this));
47
+ this.emit('open')
48
+ })
49
+
50
+ this.socket.on('error', e=>{
51
+ this.emit('error', e)
52
+ })
53
+
54
+ this.socket.on('close', ()=>{
55
+ this.emit('close');
56
+ })
57
+
58
+ }
59
+
60
+ onTCPSocketMessage( data ) {
61
+ this.rxCounter++;
62
+ this.rxBytes += data.byteLength
63
+ this.lastTxRxTime = Date.now();
64
+ // console.log('>> congRx data.len:', data.byteLength )
65
+ // console.log('>> cong.rxi, rxi_zero:', this.congRx.rxi, this.congRx.rxi_zero )
66
+ this.emit('socket_data', data );
67
+
68
+ }
69
+
70
+ socket_send(data) {
71
+ if( this.socket?.readyState === 'open'){
72
+ // console.log('tcp send raw payload:', data)
73
+ let packData = pack(data);
74
+ // console.log('tcp send cong packed:', packData)
75
+ this.socket.write( packData )
76
+ this.txCounter++;
77
+ this.txBytes += packData.byteLength;
78
+ this.lastTxRxTime = Date.now();
79
+ }else{
80
+ console.log('.')
81
+ }
82
+ }
83
+
84
+ }
85
+
86
+
87
+
88
+