iosignal-cli 1.3.4 → 1.7.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 +404 -404
- package/auth_file.json +13 -13
- package/auth_file.mjs +23 -23
- package/bin/getVersion.js +8 -8
- package/bin/io-client.js +396 -396
- package/bin/io-keygen.js +45 -45
- package/bin/io-server.js +103 -103
- package/bin/ioip.js +6 -6
- package/bin/serverInfo.js +67 -67
- package/package.json +42 -42
- package/test_auth_redis/redis_addAdmin.js +32 -32
- package/test_auth_redis/redis_addMultipleDevice.js +29 -29
- package/test_auth_redis/redis_add_get_device.js +24 -24
- package/test_auth_redis/server-Auth_Redis.js +12 -12
package/README.md
CHANGED
|
@@ -1,405 +1,405 @@
|
|
|
1
|
-
# IOSignal CLI
|
|
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
|
-
|
|
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.
|
|
6
|
-
|
|
7
|
-
[Kr] iosignal 은 웹브라우저, node.js , arduino 간의 실시간 통신을 지원합니다. 또한 보안 인증과 암호통신 기능도 제공됩니다. 시그널링 프로토콜이 내장되어 있어서 서버는 프로그래밍 없이 사용 가능합니다.
|
|
8
|
-
|
|
9
|
-
## supports
|
|
10
|
-
|
|
11
|
-
Windows, Mac, and Linux.
|
|
12
|
-
|
|
13
|
-
## install
|
|
14
|
-
|
|
15
|
-
Linux, Mac and shell
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
# global install.
|
|
19
|
-
$ npm install -g iosignal-cli
|
|
20
|
-
|
|
21
|
-
# If you encounter a permissions error, use sudo.
|
|
22
|
-
$ sudo npm install -g iosignal-cli
|
|
23
|
-
```
|
|
24
|
-
windows as admin permission
|
|
25
|
-
```sh
|
|
26
|
-
# global install.
|
|
27
|
-
$ npm install -g iosignal-cli
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## IOSignal server
|
|
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
|
-
|
|
77
|
-
```sh
|
|
78
|
-
% io-server -L 8888
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### WebSocket and CongSocket can be supported together.
|
|
82
|
-
|
|
83
|
-
- This allows the Arduino and web browser to communicate with each other.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```sh
|
|
87
|
-
% io-server -l 7777 -L 8888
|
|
88
|
-
opening WebSocket Server: 7777
|
|
89
|
-
opening CongSocket Server: 8888
|
|
90
|
-
|
|
91
|
-
┌───────────────────────────────────────────┐
|
|
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
|
-
│ │
|
|
111
|
-
└───────────────────────────────────────────┘
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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`.
|
|
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
|
-
└─────────┴───────────────────────┘
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## iosignal client
|
|
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)
|
|
210
|
-
|
|
211
|
-
```sh
|
|
212
|
-
% io -c ws://localhost:7777
|
|
213
|
-
{ connect: 'ws://localhost:7777' }
|
|
214
|
-
Connecting to ws://localhost:7777
|
|
215
|
-
ready: cid: ?cybL
|
|
216
|
-
>
|
|
217
|
-
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
```sh
|
|
221
|
-
% io -c cong://localhost:8888
|
|
222
|
-
{ connect: 'cong://localhost:8888' }
|
|
223
|
-
Connecting to cong://localhost:8888
|
|
224
|
-
ready: cid: ?yVAQ
|
|
225
|
-
>
|
|
226
|
-
|
|
227
|
-
```
|
|
228
|
-
|
|
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
|
-
```
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
## tutorial
|
|
264
|
-
|
|
265
|
-
### signaling
|
|
266
|
-
|
|
267
|
-
- multi-cast: publish/subscribe channel_name
|
|
268
|
-
- uni-cast: use cid(communication id)
|
|
269
|
-
|
|
270
|
-
1. start server
|
|
271
|
-
```sh
|
|
272
|
-
$ io-server -l 7777
|
|
273
|
-
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
2. start client A.
|
|
277
|
-
|
|
278
|
-
```sh
|
|
279
|
-
$ io -c localhost:7777
|
|
280
|
-
Connecting to ws://localhost:7777
|
|
281
|
-
ready: cid: ?c3Nr
|
|
282
|
-
|
|
283
|
-
> .subscribe channel_name
|
|
284
|
-
# subscribe some channel
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
3. start client B.
|
|
288
|
-
```sh
|
|
289
|
-
$ io -c localhost:7777
|
|
290
|
-
Connecting to ws://localhost:7777
|
|
291
|
-
ready: cid: ?rr75
|
|
292
|
-
>
|
|
293
|
-
# multicast.
|
|
294
|
-
> .signal channel_name some_message
|
|
295
|
-
|
|
296
|
-
# unicast to A.
|
|
297
|
-
> .signal ?c3Nr@ direct_message
|
|
298
|
-
# IMPORTANT.
|
|
299
|
-
# unicast signal tag must include '@' charactor. tag = 'cid' + @
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
### authentication
|
|
303
|
-
|
|
304
|
-
#### type1. auth data from file.
|
|
305
|
-
|
|
306
|
-
- for personal use only
|
|
307
|
-
- raw plain password string. (Not Hashed)
|
|
308
|
-
- each device have 4 values: `deviceId`, `deviceKey`, `deviceCId`, `level`
|
|
309
|
-
- you can find sample auth_file.mjs and auth_file.json in root folder.
|
|
310
|
-
```sh
|
|
311
|
-
$ io-server -l 7777 -d auth_file.json
|
|
312
|
-
or
|
|
313
|
-
$ io-server -l 7777 -d auth_file.mjs
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
auth_file.json structure
|
|
317
|
-
- deviceId string size limit: 8 charactors.
|
|
318
|
-
- No passphrase string limit. (It will be digested 32bytes with sha256.)
|
|
319
|
-
- CID string size limit: current 20 chars. can be changed.
|
|
320
|
-
- JSON file does not support comment.
|
|
321
|
-
```js
|
|
322
|
-
[
|
|
323
|
-
["id","key","cid",0],
|
|
324
|
-
["did2","did2key","did2-cid",0],
|
|
325
|
-
["uno3","uno3-key","uno3-cid",1]
|
|
326
|
-
]
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
### auth_file.mjs
|
|
330
|
-
- support comments.
|
|
331
|
-
|
|
332
|
-
```js
|
|
333
|
-
// *.mjs file support comments.
|
|
334
|
-
export const authInfo = [
|
|
335
|
-
// device id, key, communication id, level:Number(0~255)
|
|
336
|
-
["did","passowrd","cid",0],
|
|
337
|
-
["device1","device1_key","device1_cid",0],
|
|
338
|
-
["root","root-key","root-cid",255], // default admin_root level is 255
|
|
339
|
-
["uno","uno-key","uno",1]
|
|
340
|
-
]
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
#### type2. auth data from Redis(or other DataBase)
|
|
346
|
-
- Recommended
|
|
347
|
-
- you can find source and examples here.
|
|
348
|
-
- `iosiganl` "/src/auth/"
|
|
349
|
-
- `iosignal-cli` "/test_auth_redis/"
|
|
350
|
-
|
|
351
|
-
Before running the server, you need to make sure that your Redis server is up and running and that you have registered your device credentials. A simple credentials enrollment example is included in the source above.
|
|
352
|
-
|
|
353
|
-
start server with local redis-auth-system
|
|
354
|
-
```sh
|
|
355
|
-
$ io-server -l 7777 -r # redis://localhost:6379
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
#### auth client
|
|
360
|
-
1. start auth server.
|
|
361
|
-
2. connect and login
|
|
362
|
-
|
|
363
|
-
```sh
|
|
364
|
-
$ io -c localhost:7777
|
|
365
|
-
ready: cid: ?YXDr
|
|
366
|
-
> .login uno3 uno3-key
|
|
367
|
-
try manual login: uno3
|
|
368
|
-
> >> QUOTA_LEVEL : 1
|
|
369
|
-
current quota: {"signalSize":255,"publishCounter":10,"trafficRate":100000}
|
|
370
|
-
ready: cid: uno3-cid
|
|
371
|
-
|
|
372
|
-
# now device have (pre-registered) CID.
|
|
373
|
-
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
## Support for both web browsers and Arduino
|
|
377
|
-
### Specifying two types of ports
|
|
378
|
-
IOSignal uses websockets for web browser peer connections. If you want to use an Arduino connection, you must specify the use of the CongSocket port using the -L option.
|
|
379
|
-
|
|
380
|
-
The -l option specifies the Websocket port, and the -L option specifies the CongSocket port for the Arduino.
|
|
381
|
-
|
|
382
|
-
```sh
|
|
383
|
-
|
|
384
|
-
$ io-server -l 7777 -L 8888
|
|
385
|
-
# -l option for WebSocket port
|
|
386
|
-
# -L option for CongSocket port ( Arduino connection)
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
### Local Network IP Address
|
|
390
|
-
|
|
391
|
-
If you need the IP address of the server to access it from your local network, you can check the local network IP address of the server.
|
|
392
|
-
|
|
393
|
-
```sh
|
|
394
|
-
$ ioip
|
|
395
|
-
192.168.0.72
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
### IOSignal Arduino Library
|
|
400
|
-
|
|
401
|
-
Search for `IOSignal` in the Arduino library manager and install it, or see the [`iosignal-arduino`](https://github.com/remocons/iosignal-arduino) github repository
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
## iosignal stack
|
|
1
|
+
# IOSignal CLI
|
|
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
|
+
|
|
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.
|
|
6
|
+
|
|
7
|
+
[Kr] iosignal 은 웹브라우저, node.js , arduino 간의 실시간 통신을 지원합니다. 또한 보안 인증과 암호통신 기능도 제공됩니다. 시그널링 프로토콜이 내장되어 있어서 서버는 프로그래밍 없이 사용 가능합니다.
|
|
8
|
+
|
|
9
|
+
## supports
|
|
10
|
+
|
|
11
|
+
Windows, Mac, and Linux.
|
|
12
|
+
|
|
13
|
+
## install
|
|
14
|
+
|
|
15
|
+
Linux, Mac and shell
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
# global install.
|
|
19
|
+
$ npm install -g iosignal-cli
|
|
20
|
+
|
|
21
|
+
# If you encounter a permissions error, use sudo.
|
|
22
|
+
$ sudo npm install -g iosignal-cli
|
|
23
|
+
```
|
|
24
|
+
windows as admin permission
|
|
25
|
+
```sh
|
|
26
|
+
# global install.
|
|
27
|
+
$ npm install -g iosignal-cli
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## IOSignal server
|
|
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
|
+
|
|
77
|
+
```sh
|
|
78
|
+
% io-server -L 8888
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### WebSocket and CongSocket can be supported together.
|
|
82
|
+
|
|
83
|
+
- This allows the Arduino and web browser to communicate with each other.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
% io-server -l 7777 -L 8888
|
|
88
|
+
opening WebSocket Server: 7777
|
|
89
|
+
opening CongSocket Server: 8888
|
|
90
|
+
|
|
91
|
+
┌───────────────────────────────────────────┐
|
|
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
|
+
│ │
|
|
111
|
+
└───────────────────────────────────────────┘
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
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`.
|
|
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
|
+
└─────────┴───────────────────────┘
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## iosignal client
|
|
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)
|
|
210
|
+
|
|
211
|
+
```sh
|
|
212
|
+
% io -c ws://localhost:7777
|
|
213
|
+
{ connect: 'ws://localhost:7777' }
|
|
214
|
+
Connecting to ws://localhost:7777
|
|
215
|
+
ready: cid: ?cybL
|
|
216
|
+
>
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
```sh
|
|
221
|
+
% io -c cong://localhost:8888
|
|
222
|
+
{ connect: 'cong://localhost:8888' }
|
|
223
|
+
Connecting to cong://localhost:8888
|
|
224
|
+
ready: cid: ?yVAQ
|
|
225
|
+
>
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
|
|
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
|
+
```
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
## tutorial
|
|
264
|
+
|
|
265
|
+
### signaling
|
|
266
|
+
|
|
267
|
+
- multi-cast: publish/subscribe channel_name
|
|
268
|
+
- uni-cast: use cid(communication id)
|
|
269
|
+
|
|
270
|
+
1. start server
|
|
271
|
+
```sh
|
|
272
|
+
$ io-server -l 7777
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
2. start client A.
|
|
277
|
+
|
|
278
|
+
```sh
|
|
279
|
+
$ io -c localhost:7777
|
|
280
|
+
Connecting to ws://localhost:7777
|
|
281
|
+
ready: cid: ?c3Nr
|
|
282
|
+
|
|
283
|
+
> .subscribe channel_name
|
|
284
|
+
# subscribe some channel
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
3. start client B.
|
|
288
|
+
```sh
|
|
289
|
+
$ io -c localhost:7777
|
|
290
|
+
Connecting to ws://localhost:7777
|
|
291
|
+
ready: cid: ?rr75
|
|
292
|
+
>
|
|
293
|
+
# multicast.
|
|
294
|
+
> .signal channel_name some_message
|
|
295
|
+
|
|
296
|
+
# unicast to A.
|
|
297
|
+
> .signal ?c3Nr@ direct_message
|
|
298
|
+
# IMPORTANT.
|
|
299
|
+
# unicast signal tag must include '@' charactor. tag = 'cid' + @
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### authentication
|
|
303
|
+
|
|
304
|
+
#### type1. auth data from file.
|
|
305
|
+
|
|
306
|
+
- for personal use only
|
|
307
|
+
- raw plain password string. (Not Hashed)
|
|
308
|
+
- each device have 4 values: `deviceId`, `deviceKey`, `deviceCId`, `level`
|
|
309
|
+
- you can find sample auth_file.mjs and auth_file.json in root folder.
|
|
310
|
+
```sh
|
|
311
|
+
$ io-server -l 7777 -d auth_file.json
|
|
312
|
+
or
|
|
313
|
+
$ io-server -l 7777 -d auth_file.mjs
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
auth_file.json structure
|
|
317
|
+
- deviceId string size limit: 8 charactors.
|
|
318
|
+
- No passphrase string limit. (It will be digested 32bytes with sha256.)
|
|
319
|
+
- CID string size limit: current 20 chars. can be changed.
|
|
320
|
+
- JSON file does not support comment.
|
|
321
|
+
```js
|
|
322
|
+
[
|
|
323
|
+
["id","key","cid",0],
|
|
324
|
+
["did2","did2key","did2-cid",0],
|
|
325
|
+
["uno3","uno3-key","uno3-cid",1]
|
|
326
|
+
]
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### auth_file.mjs
|
|
330
|
+
- support comments.
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
// *.mjs file support comments.
|
|
334
|
+
export const authInfo = [
|
|
335
|
+
// device id, key, communication id, level:Number(0~255)
|
|
336
|
+
["did","passowrd","cid",0],
|
|
337
|
+
["device1","device1_key","device1_cid",0],
|
|
338
|
+
["root","root-key","root-cid",255], // default admin_root level is 255
|
|
339
|
+
["uno","uno-key","uno",1]
|
|
340
|
+
]
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
#### type2. auth data from Redis(or other DataBase)
|
|
346
|
+
- Recommended
|
|
347
|
+
- you can find source and examples here.
|
|
348
|
+
- `iosiganl` "/src/auth/"
|
|
349
|
+
- `iosignal-cli` "/test_auth_redis/"
|
|
350
|
+
|
|
351
|
+
Before running the server, you need to make sure that your Redis server is up and running and that you have registered your device credentials. A simple credentials enrollment example is included in the source above.
|
|
352
|
+
|
|
353
|
+
start server with local redis-auth-system
|
|
354
|
+
```sh
|
|
355
|
+
$ io-server -l 7777 -r # redis://localhost:6379
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
#### auth client
|
|
360
|
+
1. start auth server.
|
|
361
|
+
2. connect and login
|
|
362
|
+
|
|
363
|
+
```sh
|
|
364
|
+
$ io -c localhost:7777
|
|
365
|
+
ready: cid: ?YXDr
|
|
366
|
+
> .login uno3 uno3-key
|
|
367
|
+
try manual login: uno3
|
|
368
|
+
> >> QUOTA_LEVEL : 1
|
|
369
|
+
current quota: {"signalSize":255,"publishCounter":10,"trafficRate":100000}
|
|
370
|
+
ready: cid: uno3-cid
|
|
371
|
+
|
|
372
|
+
# now device have (pre-registered) CID.
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Support for both web browsers and Arduino
|
|
377
|
+
### Specifying two types of ports
|
|
378
|
+
IOSignal uses websockets for web browser peer connections. If you want to use an Arduino connection, you must specify the use of the CongSocket port using the -L option.
|
|
379
|
+
|
|
380
|
+
The -l option specifies the Websocket port, and the -L option specifies the CongSocket port for the Arduino.
|
|
381
|
+
|
|
382
|
+
```sh
|
|
383
|
+
|
|
384
|
+
$ io-server -l 7777 -L 8888
|
|
385
|
+
# -l option for WebSocket port
|
|
386
|
+
# -L option for CongSocket port ( Arduino connection)
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Local Network IP Address
|
|
390
|
+
|
|
391
|
+
If you need the IP address of the server to access it from your local network, you can check the local network IP address of the server.
|
|
392
|
+
|
|
393
|
+
```sh
|
|
394
|
+
$ ioip
|
|
395
|
+
192.168.0.72
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
### IOSignal Arduino Library
|
|
400
|
+
|
|
401
|
+
Search for `IOSignal` in the Arduino library manager and install it, or see the [`iosignal-arduino`](https://github.com/remocons/iosignal-arduino) github repository
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
## iosignal stack
|
|
405
405
|

|