iosignal-cli 1.1.0 → 1.3.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/README.md CHANGED
@@ -1,96 +1,264 @@
1
1
  # IOSignal CLI
2
2
 
3
+ iosignal supports real-time communication between web browsers, node.js, and arduino. It also provides secure authentication and encrypted communication. The signaling protocol is built-in, so the server can be used without programming.
4
+
3
5
  iosignal-cli program that makes it simple to run a iosignal server and client. It uses the [iosignal](https://www.npmjs.com/package/iosignal) library and uses Redis for authentication database functionality.
4
6
 
7
+ [Kr] iosignal 은 웹브라우저, node.js , arduino 간의 실시간 통신을 지원합니다. 또한 보안 인증과 암호통신 기능도 제공됩니다. 시그널링 프로토콜이 내장되어 있어서 서버는 프로그래밍 없이 사용 가능합니다.
8
+
5
9
  ## supports
10
+
6
11
  Windows, Mac, and Linux.
7
12
 
8
13
  ## install
14
+
9
15
  Linux, Mac and shell
16
+
10
17
  ```sh
11
18
  # global install.
12
19
  $ npm install -g iosignal-cli
13
20
 
14
- # If NO Permissioin error, use sudo prefix.
21
+ # If you encounter a permissions error, use sudo.
15
22
  $ sudo npm install -g iosignal-cli
16
-
17
23
  ```
18
-
19
24
  windows as admin permission
20
25
  ```sh
21
26
  # global install.
22
27
  $ npm install -g iosignal-cli
23
28
  ```
24
29
 
25
-
26
30
  ## IOSignal server
27
31
 
32
+ - use `io-server` command.
33
+ - `ios` is a shortened name for io-server.
34
+
35
+ ```
36
+ % io-server -h
37
+ Usage: io-server [options] (--listen <port> )
38
+
39
+ Options:
40
+ -V, --version output the version number
41
+ -l, --listen <port> listen on port (start WebSocket Server)
42
+ -L, --listen-congport <port> listen on cong port (start CongSocket
43
+ Server)
44
+ -d, --auth-file <path> auth data file path
45
+ -e, --auth-param <id.key.level> auth data from argument:
46
+ id.key.level,id2.key2.level2
47
+ -E, --auth-env auth data from shell env BOHO_AUTH
48
+ -r, --auth-redis connect to redis. if exist use env
49
+ REDIS_HOST, REDIS_PORT or localhost:6379
50
+ -t, --timeout <milliseconds> ping period & timeout
51
+ -m, --metric <type> show metric <number> 1:traffic, 2:echo
52
+ -s, --show-message <none|message> show receive message.
53
+ -f, --file-logger write log files.
54
+ -a, --api-list [list...] one or multiple api names: -a api_1 api_2
55
+ -o, --show-options show server init options.
56
+ -h, --help display help for command
57
+
58
+ ```
59
+
60
+ ### IOSignal over WebSocket
61
+
62
+ - Use the -l option to specify the port number for websocket connections.
63
+
64
+ - Supports web browser and node.js client access.
65
+
66
+ ```sh
67
+ % io-server -l 7777
68
+ ```
69
+
70
+ ### IOSignal Over CongSocket
71
+
72
+ - Use the -L option to specify the port number for CongSocket connections.
73
+ - CongSocket is IOSignal's own protocol that is lighter than WebSocket.
74
+ - It was developed specifically for low-end devices like Arduino.
75
+ - Supports Arduino and node.js client access.
76
+
28
77
  ```sh
29
- $ io-server
30
- # start server with default option.
31
- # default. open port 7777 with WebSocket.
78
+ % io-server -L 8888
79
+ ```
80
+
81
+ ### WebSocket and CongSocket can be supported together.
32
82
 
33
- ┌─────────────────────────────────────────┐
34
-
35
- WebSocket: Browser or nodejs client
36
-
37
- - Local: ws://localhost:7777
38
- - Network: ws://192.168.0.204:7777
39
-
40
- └─────────────────────────────────────────┘
83
+ - This allows the Arduino and web browser to communicate with each other.
41
84
 
42
85
 
43
- $ io-server -l 5555
44
- # you can specify listen port number
86
+ ```sh
87
+ % io-server -l 7777 -L 8888
88
+ opening WebSocket Server: 7777
89
+ opening CongSocket Server: 8888
45
90
 
46
91
  ┌───────────────────────────────────────────┐
47
-
48
- WebSocket: Browser or nodejs client
49
-
50
- - Local: ws://localhost:5555
51
- - Network: ws://192.168.0.204:5555
52
-
53
- CongSocket: nodejs client or CLI
54
-
55
- - Local: cong://localhost:8888
56
- - Network: cong://192.168.0.204:8888
57
-
58
- CongSocket: Arduino client
59
-
60
- - host: 192.168.0.204
61
- - port: 8888
62
-
92
+ │ │
93
+ │ Serving │
94
+ │ │
95
+ │ IOSignal Over WebSocket │
96
+ │ │
97
+ │ Web Browser & Node.js │
98
+ │ - Local: ws://localhost:7777
99
+ │ - Network: ws://192.168.0.72:7777 │
100
+ │ │
101
+ │ IOSignal Over CongSocket │
102
+ │ │
103
+ │ Node.js │
104
+ │ - Local: cong://localhost:8888 │
105
+ - Network: cong://192.168.0.72:8888 │
106
+ │ │
107
+ │ Arduino │
108
+ │ - host: 192.168.0.72 │
109
+ │ - port: 8888 │
110
+ │ │
63
111
  └───────────────────────────────────────────┘
64
112
 
65
113
 
66
114
 
67
- $ io-server -l 0 -L 5555
68
- # use number 0 to disable WebSocket service.
115
+ ```
116
+
117
+ ## Monitor Server
118
+
119
+ ### Viewing incoming messages
120
+
121
+ - To view server incoming signal messages, use the -s option.
122
+ - `ios` is a shortened name for `io-server`.
69
123
 
124
+ ```
125
+ % ios -l 7777 -s message
126
+ ...
127
+
128
+ #1(undefined) [ CID_REQ ] <Buffer c1>
129
+ #1(?ayTp) [ SIGNAL ] <Buffer d0 02 68 69 00>
130
+ #1(?ayTp) [ PING ] <Buffer cd>
131
+
132
+ ```
133
+
134
+ ### Viewing metrics
135
+
136
+ - `-m 1` : channels, clients, traffic
137
+ - `-m 2` : clients
138
+ - `-m 3` : channels
139
+
140
+ ```sh
141
+
142
+ $ ios -l 7777 -m 1
143
+ ...
144
+
145
+ monitor metric type: 1
146
+ ┌─────────┬───────────┬───────────┬──────────┬──────────┬──────────────┐
147
+ │ (index) │ rss │ heapTotal │ heapUsed │ external │ arrayBuffers │
148
+ ├─────────┼───────────┼───────────┼──────────┼──────────┼──────────────┤
149
+ │ 0 │ 108232704 │ 57294848 │ 24523112 │ 1389925 │ 59260 │
150
+ └─────────┴───────────┴───────────┴──────────┴──────────┴──────────────┘
151
+ ┌─────────┬──────────┬─────────┬──────────┬─────────┬─────────┐
152
+ │ (index) │ lastSSID │ remotes │ channels │ txBytes │ rxBytes │
153
+ ├─────────┼──────────┼─────────┼──────────┼─────────┼─────────┤
154
+ │ 0 │ 2 │ 2 │ 1 │ 57 │ 18 │
155
+ └─────────┴──────────┴─────────┴──────────┴─────────┴─────────┘
156
+
157
+
158
+ $ ios -l 7777 -m 2
159
+ ...
160
+ monitor metric type: 2
161
+ ┌─────────┬───────────────┐
162
+ │ (index) │ Values │
163
+ ├─────────┼───────────────┤
164
+ │ 0 │ '#1:?9P-i(7)' │
165
+ │ 1 │ '#2:?zNuW(7)' │
166
+ └─────────┴───────────────┘
167
+
168
+
169
+ $ ios -l 7777 -m 3
170
+ ...
171
+ monitor metric type: 3
172
+ ┌─────────┬───────────────────────┐
173
+ │ (index) │ Values │
174
+ ├─────────┼───────────────────────┤
175
+ │ 0 │ 'PRIVATE:#homeButton' │
176
+ └─────────┴───────────────────────┘
70
177
  ```
71
178
 
72
179
  ## iosignal client
73
180
 
181
+ - use `io-client` command.
182
+ - `io` is a shortened name for io-client.
183
+
184
+ ### usage
185
+
186
+ ```
187
+ % io -h
188
+ Usage: io [options] (--connect <url> )
189
+
190
+ Options:
191
+ -V, --version output the version number
192
+ -t, --timeout <milliseconds> ping period & timeout
193
+ -c, --connect <url> connect to a server
194
+ -i, --id <id> userId
195
+ -k, --key <key> userKey
196
+ -a, --auth-idKey <idkey> auth id.key
197
+ -j, --join-channel <channelName> join to channel
198
+ -h, --help display help for command
199
+
200
+ ```
201
+
202
+ ### connection
203
+ - To connect to a server, specify the server address and port number with the -c option.
204
+
205
+ - The server address specifies one of the following protocols: ws, wss, or cong.
206
+ - `ws`://url:port (WebSocket)
207
+ - In the case of localhost, ws can be omitted.
208
+ - `wss`://url:port (WebSocket TLS)
209
+ - `cong`://url:port ( CongSocket)
74
210
 
75
211
  ```sh
76
- $ io
77
- # io is an alias name of io-clinet
78
- # connect to localhost:7777 with websocket.
212
+ % io -c ws://localhost:7777
213
+ { connect: 'ws://localhost:7777' }
214
+ Connecting to ws://localhost:7777
215
+ ready: cid: ?cybL
216
+ >
79
217
 
80
- # use -c to define websocket url and port number.
81
- $ io -c wss://websocket_server_url:port
82
- $ io -c ws://localhost:7777
218
+ ```
83
219
 
84
- # support ws or wss(TLS).
220
+ ```sh
221
+ % io -c cong://localhost:8888
222
+ { connect: 'cong://localhost:8888' }
223
+ Connecting to cong://localhost:8888
224
+ ready: cid: ?yVAQ
225
+ >
85
226
 
86
227
  ```
87
228
 
88
- ## iosignal commands
229
+ - On successful client connection, the `cid` is displayed with a `ready` indication.
230
+ - The CID is a unique communication ID issued by the server.
231
+ - The CID of an unauthenticated client changes with each connection.
232
+ - Authenticated clients use a fixed, predefined CID.
233
+ - You can use CIDs for one-to-one communication or CID subscriptions.
234
+
235
+
236
+ ### io-client cli command list
237
+
238
+ - When connected to the server with the io-client CLI program, you can communicate, subscribe, and issue signals with the commands below.
239
+ - The CLI program can also communicate with browsers and Arduino connected to the server.
240
+
241
+ ```
242
+ io-client cli commands:
243
+ .sig
244
+ .signal .publish .pub is the same as .sig.
245
+ .sub
246
+ .subscribe is the same as .sub.
247
+ .listen : subscirbe and print the received messages to the screen.
248
+ .unsub
249
+ .ping
250
+ .pong
251
+ .id
252
+ .iam
253
+ .open
254
+ .connect
255
+ .close
256
+ .login
257
+ .auth
258
+ .quit
259
+ .exit
260
+ ```
89
261
 
90
- - subscribe('tag')
91
- - publish('tag', message )
92
- - signal('tag', message ) // same with publish
93
- - not ready whole document.
94
262
 
95
263
  ## tutorial
96
264
 
@@ -101,18 +269,16 @@ $ io -c ws://localhost:7777
101
269
 
102
270
  1. start server
103
271
  ```sh
104
- $ io-server # alias ios
272
+ $ io-server -l 7777
105
273
 
106
274
  ```
107
275
 
108
276
  2. start client A.
109
277
 
110
278
  ```sh
111
- $ io
279
+ $ io -c localhost:7777
112
280
  Connecting to ws://localhost:7777
113
281
  ready: cid: ?c3Nr
114
- # connected and receive client cid.
115
- # CID(Communicaion Id of the io client.)
116
282
 
117
283
  > .subscribe channel_name
118
284
  # subscribe some channel
@@ -120,12 +286,10 @@ ready: cid: ?c3Nr
120
286
 
121
287
  3. start client B.
122
288
  ```sh
123
- $ io
289
+ $ io -c localhost:7777
124
290
  Connecting to ws://localhost:7777
125
291
  ready: cid: ?rr75
126
292
  >
127
- # connected and received cid.
128
-
129
293
  # multicast.
130
294
  > .signal channel_name some_message
131
295
 
@@ -144,9 +308,9 @@ ready: cid: ?rr75
144
308
  - each device have 4 values: `deviceId`, `deviceKey`, `deviceCId`, `level`
145
309
  - you can find sample auth_file.mjs and auth_file.json in root folder.
146
310
  ```sh
147
- $ io-server -d auth_file.json
311
+ $ io-server -l 7777 -d auth_file.json
148
312
  or
149
- $ io-server -d auth_file.mjs
313
+ $ io-server -l 7777 -d auth_file.mjs
150
314
  ```
151
315
 
152
316
  auth_file.json structure
@@ -188,7 +352,7 @@ Before running the server, you need to make sure that your Redis server is up an
188
352
 
189
353
  start server with local redis-auth-system
190
354
  ```sh
191
- $ io-server -r // redis://localhost:6379
355
+ $ io-server -l 7777 -r # redis://localhost:6379
192
356
  ```
193
357
 
194
358
 
@@ -197,7 +361,7 @@ $ io-server -r // redis://localhost:6379
197
361
  2. connect and login
198
362
 
199
363
  ```sh
200
- $ io
364
+ $ io -c localhost:7777
201
365
  ready: cid: ?YXDr
202
366
  > .login uno3 uno3-key
203
367
  try manual login: uno3
package/bin/io-client.js CHANGED
@@ -95,7 +95,6 @@ program
95
95
  .version(version)
96
96
  .usage('[options] (--connect <url> )')
97
97
  .option('-t, --timeout <milliseconds>', 'ping period & timeout')
98
- .option('-s, --show-message <none|message|frame>', 'show receive message. ')
99
98
  .option('-c, --connect <url>', 'connect to a server')
100
99
  .option('-i, --id <id>', 'userId')
101
100
  .option('-k, --key <key>', 'userKey')
@@ -104,12 +103,12 @@ program
104
103
  .parse(process.argv)
105
104
 
106
105
  const options = program.opts()
106
+ const defaultWebSocketPort = 7777;
107
107
 
108
108
  console.log(options)
109
109
 
110
-
111
110
  if (!options.connect) {
112
- options.connect = 'localhost:' + serverOption.port;
111
+ options.connect = 'localhost:' + defaultWebSocketPort;
113
112
  }
114
113
 
115
114
 
@@ -389,6 +388,7 @@ wsConsole.on('line', (data) => {
389
388
  )
390
389
  }
391
390
  } else {
391
+ io.send( data )
392
392
  }
393
393
  wsConsole.prompt()
394
394
  })
package/bin/io-server.js CHANGED
@@ -22,7 +22,7 @@ program
22
22
  .option('-r, --auth-redis', 'connect to redis. if exist use env REDIS_HOST, REDIS_PORT or localhost:6379')
23
23
  .option('-t, --timeout <milliseconds>', 'ping period & timeout')
24
24
  .option('-m, --metric <type>', 'show metric <number> 1:traffic, 2:echo')
25
- .option('-s, --show-message <none|message|frame>', 'show receive message. ')
25
+ .option('-s, --show-message <none|message>', 'show receive message. ')
26
26
  .option('-f, --file-logger', 'write log files.')
27
27
  .option('-a, --api-list [list...]', 'one or multiple api names: -a api_1 api_2 ')
28
28
  .option('-o, --show-options', 'show server init options.')
@@ -30,7 +30,6 @@ program
30
30
 
31
31
  const options = program.opts()
32
32
 
33
-
34
33
  if (options.fileLogger) {
35
34
  serverOption.fileLogger.connection.use = true;
36
35
  serverOption.fileLogger.auth.use = true;
@@ -38,7 +37,7 @@ if (options.fileLogger) {
38
37
  }
39
38
 
40
39
  if (options.listen) {
41
- serverOption.port = options.listen
40
+ serverOption.port = parseInt(options.listen)
42
41
  }
43
42
 
44
43
  if (options.listenCongport) {
@@ -77,7 +76,7 @@ if (options.authFile) {
77
76
  redisClient.connect();
78
77
  authManager = new Auth_Redis(redisClient)
79
78
  } else {
80
- console.log("No authentication support.")
79
+ // console.log("No authentication support.")
81
80
 
82
81
  }
83
82
 
package/bin/serverInfo.js CHANGED
@@ -18,25 +18,48 @@ function getNetworkAddress (){
18
18
 
19
19
 
20
20
  export function serverInfo ( wsPort, congPort ){
21
+ // console.log('wsPort', wsPort, 'congPort', congPort)
21
22
  let ip = getNetworkAddress();
22
- let message = chalk.green('WebSocket: Browser or nodejs client');
23
+ let message
24
+
25
+ if( wsPort || congPort ){
26
+ message = chalk.green('Serving');
27
+ }else{
28
+ message = chalk.green('please use -l and -L option to select port number.');
29
+ message += chalk.yellow('\n\n $ io-server -l 7777');
30
+ message += chalk.green(' // iosignal over websocket.');
31
+ message += chalk.yellow('\n\n $ io-server -L 8888');
32
+ message += chalk.green(' // iosignal over congsocket.');
33
+ message += chalk.yellow('\n\n $ io-server -l 7777 -L 8888');
34
+ message += chalk.green(' // suppport both.');
35
+ message += chalk.yellow('\n\n $ io-server -h');
36
+ message += chalk.green(' // display help');
37
+ }
23
38
 
24
39
  const prefix = '- '
25
40
  const space = ' '
26
41
 
27
- message += `\n\n${chalk.bold(`${prefix}Local:`)}${space}ws://localhost:${wsPort}`;
28
- message += `\n${chalk.bold('- Network:')} ws://${ip}:${wsPort}`;
42
+ if(wsPort){
43
+ message += `\n\n`;
44
+ message += chalk.green('IOSignal Over WebSocket');
45
+ message += chalk.yellow('\n\n Web Browser & Node.js');
46
+ message += `\n ${chalk.bold(`${prefix}Local:`)}${space}ws://localhost:${wsPort}`;
47
+ message += `\n ${chalk.bold('- Network:')} ws://${ip}:${wsPort}`;
48
+ }else{
49
+
50
+ }
29
51
 
30
52
  if(congPort){
31
53
  message += `\n\n`;
32
- message += chalk.green('CongSocket: nodejs client or CLI');
33
- message += `\n\n${chalk.bold(`${prefix}Local:`)}${space}cong://localhost:${congPort}`;
34
- message += `\n${chalk.bold('- Network:')} cong://${ip}:${congPort}`;
54
+ message += chalk.green('IOSignal Over CongSocket');
55
+ message += chalk.yellow('\n\n Node.js');
35
56
 
36
- message += `\n\n`;
37
- message += chalk.green('CongSocket: Arduino client');
38
- message += `\n\n${chalk.bold(`${prefix}host:`)} ${ip}`;
39
- message += `\n${chalk.bold('- port:')} ${congPort }`;
57
+ message += `\n ${chalk.bold(`${prefix}Local:`)}${space}cong://localhost:${congPort}`;
58
+ message += `\n ${chalk.bold('- Network:')} cong://${ip}:${congPort}`;
59
+
60
+ message += chalk.yellow('\n\n Arduino');
61
+ message += `\n ${chalk.bold(`${prefix}host:`)} ${ip}`;
62
+ message += `\n ${chalk.bold('- port:')} ${congPort }`;
40
63
 
41
64
  }
42
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iosignal-cli",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "IOSignal server and client CLI program.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,7 @@
19
19
  "boxen": "^7.1.1",
20
20
  "chalk": "^5.3.0",
21
21
  "commander": "^11.1.0",
22
- "iosignal": "^1.0.0",
22
+ "iosignal": "^1.3.1",
23
23
  "meta-buffer-pack": "^1.3.1",
24
24
  "redis": "^4.6.12"
25
25
  },