iosignal 1.0.0 → 1.2.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,6 +1,10 @@
1
1
  # IOSignal
2
2
 
3
- This library provides a server and client for doing signaling(messaging) with peers that supports [`iosignal`](https://github.com/remocons/iosignal).
3
+ [En] iosignal supports real-time communication between web browsers, node.js, and arduino. It also provides secure authentication and encrypted communication.
4
+ The signaling protocol is built-in, so the server can be used without programming.
5
+
6
+ [Kr] iosignal 은 웹브라우저, node.js , arduino 간의 실시간 통신을 지원합니다. 또한 보안 인증과 암호통신 기능도 제공됩니다.
7
+ 시그널링 프로토콜이 내장되어 있어서 서버는 프로그래밍 없이 사용 가능합니다.
4
8
 
5
9
  ## Install
6
10
 
@@ -8,25 +12,92 @@ This library provides a server and client for doing signaling(messaging) with pe
8
12
  $ npm i iosignal
9
13
  ```
10
14
 
11
- ## Usage
15
+ ## IOSignal Server
16
+
17
+ CommonJS and ESM support both
18
+
19
+ ### ESM style
20
+
21
+ ```
22
+ import { Server } from "iosignal"
23
+ const server = new Server( { port: 7777 } )
24
+ ```
25
+
26
+ ### CJS style
27
+
28
+ ```
29
+ let { Server } = require('iosignal')
30
+ const server = new Server( { port: 7777 } )
31
+ ```
32
+
33
+ ### server options
34
+
35
+
36
+ ```js
37
+ let { Server } = require('iosignal')
38
+
39
+ const server = new Server(
40
+ {
41
+ port: 7777,
42
+ congPort: 8888,
43
+ showMetric: 2,
44
+ showMessage: 'message' // show raw signal buffer
45
+ })
46
+
47
+ ```
48
+
49
+ - port: <Number> IOSignal over WebSocket
50
+ - congPort: <Number> IOsignal over CongSocket
51
+ - showMetric: 1|2|3 show clients cid(state) info
52
+ - showMessage: "none"|"message" show signal buffer message
53
+ - timeout <milliseconds> ping period & timeout (min. 1000)
54
+
55
+ ### IOSiognal API
56
+
57
+ IOSignal API examples
58
+ - src/api_reply.js // 'echo', 'date', 'unixtime'
59
+ - src/api_sudo.js // server admin monitoring command
60
+ - src/RedisAPI.js // redis command and response service
61
+
12
62
 
13
- NodeJS Server
63
+ To register an API service with the server, use the api() method
64
+
65
+ `api('api_name', module )`
66
+
67
+ ```js
68
+ import { Server ,api_reply } from 'iosignal'
69
+ const server = new Server( { port: 7777 } )
70
+ server.api('reply', api_reply) // attach api module
14
71
  ```
15
- // ESM filename.mjs
16
- import { Server, ServerOption } from "iosignal"
17
72
 
18
- // CJS filename.cjs
19
- // let { Server, serverOption } = require('iosignal')
73
+ Example of a client calling the reply API
74
+
75
+ ```js
76
+ import { IO } from "iosignal"
77
+ const io = new IO('ws://localhost:7777')
78
+
79
+ io.on('ready', async ()=>{
80
+ let res_echo = await io.req('reply', 'echo', 'hello' )
81
+ let res_date = await io.req('reply', 'date' )
82
+ let res_unixtime = await io.req('reply', 'unixtime' )
20
83
 
21
- serverOption.showMetric = 2;
22
- serverOption.port = 7777 // websocket port for browser and nodejs app.
23
- serverOption.congPort = 8888 // additional TCP port for Arduino
24
- const server = new Server( serverOption )
25
- console.log( 'serverOption:', serverOption )
84
+ if( res_echo.ok ) console.log( res_echo.body )
85
+ if( res_date.ok ) console.log( res_date.body )
86
+ if( res_unixtime.ok ) console.log( res_unixtime.body )
87
+
88
+ });
89
+
90
+ // result
91
+ [ 'hello' ]
92
+ Fri, 09 Feb 2024 14:24:37 GMT
93
+ 1707488677
26
94
 
27
95
  ```
28
96
 
29
- NodeJS Client example
97
+
98
+ ## IOSignal Client
99
+
100
+ ### NodeJS Client
30
101
  ```
31
102
  // ESM
32
103
  import { IO } from "iosignal"
@@ -34,7 +105,7 @@ import { IO } from "iosignal"
34
105
  // CJS
35
106
  // const { IO } = require('iosignal')
36
107
 
37
- const io = new IO('wss://io.remocon.kr/ws')
108
+ const io = new IO('wss://io.iosignal.net/ws')
38
109
 
39
110
  io.on('ready', ()=>{
40
111
  console.log('ready cid:', io.cid)
@@ -49,17 +120,17 @@ io.on('error',err=>{
49
120
  console.log('err', err)
50
121
  })
51
122
 
52
-
53
123
  ```
54
124
 
55
- IIFE: WebBrowser client
56
- ```
125
+ ### Browser Client : IIFE
126
+
127
+ ```html
57
128
  <html>
58
- ...
129
+
59
130
  <script src="../dist/iosignal.min.js"></script>
60
- ...
131
+
61
132
  <script>
62
- console.log('IO', IO) // default global variable name is capital IO
133
+ console.log('IO', IO) // default global variable name is IO
63
134
 
64
135
  var io1 = new IO('ws://localhost:7777')
65
136
  var io2 = new IO('ws://localhost:7777')
@@ -106,17 +177,15 @@ IIFE: WebBrowser client
106
177
  </html>
107
178
  ```
108
179
 
109
- ESM: WebBrowser client
110
- ```
180
+ ### Browser client : ESM
181
+ ```html
111
182
  <html>
112
- ...
113
- <script type="module">
114
- import { IO, Boho, MBP, Buffer, sha256 } from "../dist/iosignal.esm.js"
115
183
 
116
- console.log('sha256.hash("hi")', sha256.hash('hi'))
184
+ <script type="module">
185
+ import { IO, Boho, MBP, Buffer } from "../dist/iosignal.esm.js"
117
186
 
118
- const = io = new IO('wss://io.remocon.kr/ws')
119
- io.listen('target#topic', (...args)={
187
+ const = io = new IO('wss://io.iosignal.net/ws')
188
+ io.listen('channel#topic', (...args)={
120
189
  console.log( args )
121
190
  })
122
191
 
@@ -125,9 +194,10 @@ ESM: WebBrowser client
125
194
  })
126
195
 
127
196
  </script>
128
- ...
197
+
129
198
  </html>
130
199
  ```
200
+
131
201
  ## Features
132
202
 
133
203
  ### Built-in Message Trasport Protocol
@@ -151,10 +221,11 @@ ESM: WebBrowser client
151
221
  ![IOSignal](./img/iosignal_stack.png)
152
222
 
153
223
  ## iosignal repositories.
154
- - Javascript: `iosignal` [ [github](https://github.com/remocons/iosignal) | [npm](https://www.npmjs.com/package/iosignal) ]
224
+ - JavaScript: `iosignal` [ [github](https://github.com/remocons/iosignal) | [npm](https://www.npmjs.com/package/iosignal) ]
155
225
  - Node.js server ( WebSocket, CongSocket)
156
226
  - Node.js client ( WebSocket, CongSocket)
157
- - Web Browser client( WebSocket)
227
+ - Web Browser Client( WebSocket)
228
+
158
229
  - Arduino client:
159
230
  - Arduino Library Manager: `IOSignal`
160
231
  - or `iosignal-arduino` [ [github](https://github.com/remocons/iosignal-arduino) ]