iosignal 1.4.2 → 1.5.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 (50) 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.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 +59 -60
  10. package/rollup.config.js +69 -69
  11. package/src/api/RedisAPI.js +68 -68
  12. package/src/api/api_constant.js +7 -7
  13. package/src/api/api_reply.js +34 -34
  14. package/src/api/api_sudo.js +96 -96
  15. package/src/auth/Auth_Env.js +78 -78
  16. package/src/auth/Auth_File.js +75 -75
  17. package/src/auth/Auth_Redis.js +50 -50
  18. package/src/auth/BohoAuth.js +168 -168
  19. package/src/client/CongPacket.js +150 -150
  20. package/src/client/IOCongSocket.js +88 -88
  21. package/src/client/IOCore.js +851 -851
  22. package/src/client/IOWS.js +81 -81
  23. package/src/client/IOWebSocket.js +95 -95
  24. package/src/common/constants.js +159 -159
  25. package/src/common/payload.js +82 -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 +449 -449
  30. package/src/server/Metric.js +154 -154
  31. package/src/server/Server.js +166 -148
  32. package/src/server/ServerRemote.js +227 -227
  33. package/src/server/ServerRemoteCore.js +467 -467
  34. package/src/server/serverOption.js +56 -55
  35. package/test-browser/favicon.ico +0 -0
  36. package/test-browser/index.html +92 -92
  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 +19 -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
@@ -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
+