iosignal 1.1.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 +101 -31
- package/dist/iosignal.cjs +2 -2
- package/dist/iosignal.esm.js +1 -1
- package/dist/iosignal.esm.js.map +1 -1
- package/dist/iosignal.min.js +2 -2
- package/dist/iosignal.min.js.map +1 -1
- package/package.json +2 -2
- package/src/client/IOCore.js +461 -569
- package/src/client/IOWebSocket.js +0 -1
- package/src/common/payload.js +77 -0
- package/src/server/Manager.js +3 -84
- package/src/server/Server.js +38 -21
- package/src/server/serverOption.js +2 -2
- package/test-browser/server.js +8 -5
- package/test-client-nodejs/client_api_reply.mjs +15 -0
- package/test-client-nodejs/stateChange.mjs +1 -1
- package/test-server/{test-Auth_Env.js → server-Auth_Env.js} +8 -6
- package/test-server/server-Auth_File.js +12 -0
- package/test-server/server-api_reply.js +6 -0
- package/test-server/server-api_sudo.js +7 -0
- package/test-server/server-commonjs.cjs +8 -7
- package/test-server/server-esm.mjs +7 -7
- package/test-server/simple-server.mjs +12 -0
- package/test-server/test-Auth_File.js +0 -9
- package/test-server/test-api_reply.js +0 -10
- package/test-server/test-api_sudo.js +0 -11
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# IOSignal
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
184
|
+
<script type="module">
|
|
185
|
+
import { IO, Boho, MBP, Buffer } from "../dist/iosignal.esm.js"
|
|
117
186
|
|
|
118
|
-
const = io = new IO('wss://io.
|
|
119
|
-
io.listen('
|
|
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,10 @@ ESM: WebBrowser client
|
|
|
151
221
|

|
|
152
222
|
|
|
153
223
|
## iosignal repositories.
|
|
154
|
-
-
|
|
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
|
|
227
|
+
- Web Browser Client( WebSocket)
|
|
158
228
|
|
|
159
229
|
- Arduino client:
|
|
160
230
|
- Arduino Library Manager: `IOSignal`
|