iosignal 5.1.2 → 5.1.4
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/dist/io.js +1 -1
- package/dist/io.js.map +1 -1
- package/dist/io.min.js +1 -1
- package/dist/io.min.js.map +1 -1
- package/dist/iosignal.cjs +9806 -0
- package/dist/iosignal.js +503 -40
- package/package.json +11 -11
- package/rollup.config.js +8 -1
- package/LICENSE +0 -21
- package/README.md +0 -78
- package/test/attach-services/RedisService.js +0 -46
- package/test/attach-services/replyService.js +0 -46
- package/test/auth_server_client/auth_server_client.js +0 -45
- package/test/pubsub-counter/pubsub-counter.js +0 -61
- package/test/subscribe-signal/cid-a-b.js +0 -94
- package/test/subscribe-signal/cs-signal-test.js +0 -47
- package/test/subscribe-signal/meta.js +0 -61
- package/test/subscribe-signal/self-listen.js +0 -40
- package/test/subscribe-signal/self-subscribe.js +0 -35
- package/test/subscribe-signal/signal-MBA.js +0 -15
- package/test/subscribe-signal/signalPack.js +0 -34
- package/test/subscribe-signal/signaling.js +0 -61
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iosignal",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.4",
|
|
4
4
|
"description": "iosignal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./dist/iosignal.js",
|
|
9
|
-
"require":
|
|
9
|
+
"require": "./dist/iosignal.cjs"
|
|
10
10
|
},
|
|
11
11
|
"./io": "./dist/io.js",
|
|
12
12
|
"./io.js": "./dist/io.js",
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
},
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@rollup/plugin-commonjs": "^
|
|
29
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
30
30
|
"@rollup/plugin-json": "^6.1.0",
|
|
31
|
-
"@rollup/plugin-node-resolve": "^
|
|
31
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
32
32
|
"@rollup/plugin-replace": "^6.0.1",
|
|
33
|
-
"@rollup/plugin-terser": "^0.
|
|
33
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
34
34
|
"@types/node": "^24.1.0",
|
|
35
|
-
"rollup": "^4.
|
|
35
|
+
"rollup": "^4.62.4",
|
|
36
36
|
"rollup-plugin-dts": "^6.2.1",
|
|
37
37
|
"typescript": "^5.8.3"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"boho": "^2.1.
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"ws": "^8.
|
|
40
|
+
"boho": "^2.1.3",
|
|
41
|
+
"meta-buffer-pack": "^2.1.3",
|
|
42
|
+
"eventemitter3": "^5.0.4",
|
|
43
|
+
"ws": "^8.21.3"
|
|
44
44
|
},
|
|
45
45
|
"optionalDependencies": {
|
|
46
46
|
"bufferutil": "^4.0.9",
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
"arduino",
|
|
66
66
|
"auth"
|
|
67
67
|
]
|
|
68
|
-
}
|
|
68
|
+
}
|
package/rollup.config.js
CHANGED
|
@@ -38,7 +38,14 @@ export default [
|
|
|
38
38
|
,{
|
|
39
39
|
input: './index.js',
|
|
40
40
|
output: [
|
|
41
|
-
{
|
|
41
|
+
{
|
|
42
|
+
file: './dist/iosignal.js',
|
|
43
|
+
format: 'es'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
file: "./dist/iosignal.cjs",
|
|
47
|
+
format: 'cjs'
|
|
48
|
+
}
|
|
42
49
|
],
|
|
43
50
|
plugins: [
|
|
44
51
|
resolve({
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Taeo Lee <sixgen@gmail.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# IOSignal
|
|
3
|
-
|
|
4
|
-
IOSignal은 웹 브라우저, Node.js, 아두이노 간의 실시간 통신을 지원합니다. 또한 안전한 인증 및 암호화된 통신을 제공합니다. 시그널링 프로토콜이 내장되어 있어 프로그래밍 없이 서버를 사용할 수 있습니다.
|
|
5
|
-
|
|
6
|
-
## JS examples
|
|
7
|
-
|
|
8
|
-
JS iosignal-examples 저장소 [[github](https://github.com/remocons/iosignal-examples)]
|
|
9
|
-
|
|
10
|
-
### react-chat
|
|
11
|
-
|
|
12
|
-
- vite react & iosignal server
|
|
13
|
-
- react client app
|
|
14
|
-
|
|
15
|
-
[](https://stackblitz.com/github/remocons/iosignal-examples/tree/main/iosignal_react-chat)
|
|
16
|
-
|
|
17
|
-
### svelte5-chat
|
|
18
|
-
- vite svelte & iosignal server
|
|
19
|
-
- svelte5 client app
|
|
20
|
-
|
|
21
|
-
[](https://stackblitz.com/github/remocons/iosignal-examples/tree/main/iosignal_svelte-chat)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### vanilla-chat
|
|
25
|
-
- vite & iosignal server
|
|
26
|
-
- vanilla js client app
|
|
27
|
-
|
|
28
|
-
[](https://stackblitz.com/github/remocons/iosignal-examples/tree/main/iosignal_vanilla-chat)
|
|
29
|
-
|
|
30
|
-
## 기능
|
|
31
|
-
|
|
32
|
-
### 내장 메시지 전송 프로토콜
|
|
33
|
-
- 채널 이름을 통한 pub/sub 멀티캐스트.
|
|
34
|
-
- 유니캐스트: CID를 통한 일대일 메시징.
|
|
35
|
-
- `CID`는 통신 ID입니다.
|
|
36
|
-
- CID 구독: CID를 사용하여 하나의 피어 구독.
|
|
37
|
-
- HomeChannel: IP 주소별 그룹화.
|
|
38
|
-
|
|
39
|
-
### 내장 보안
|
|
40
|
-
- 인증
|
|
41
|
-
- 암호화 (대칭키)
|
|
42
|
-
- E2EE (대칭키)
|
|
43
|
-
- `Boho` [ [github](https://github.com/remocons/boho) ]
|
|
44
|
-
|
|
45
|
-
## 연결
|
|
46
|
-
- 웹 브라우저는 WebSocket을 사용합니다.
|
|
47
|
-
- Node.js는 WebSocket 또는 CongSocket을 사용합니다.
|
|
48
|
-
- 아두이노는 CongSocket을 사용합니다.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## IOSignal 저장소
|
|
52
|
-
|
|
53
|
-
- JS: `iosignal-examples` 저장소 [[github](https://github.com/remocons/iosignal-examples)]
|
|
54
|
-
|
|
55
|
-
- JS: `iosignal` [ [github](https://github.com/remocons/iosignal/tree/main/packages/iosignal) | [npm](https://www.npmjs.com/package/iosignal) ]
|
|
56
|
-
- Node.js 서버 (WebSocket, CongSocket)
|
|
57
|
-
- Node.js 클라이언트 (WebSocket, CongSocket)
|
|
58
|
-
- 웹 브라우저 클라이언트 (WebSocket)
|
|
59
|
-
|
|
60
|
-
- CLI 프로그램
|
|
61
|
-
- `iosignal-cli` [ [github](https://github.com/remocons/iosignal/tree/main/packages/iosignal-cli) | [npm](https://www.npmjs.com/package/iosignal-cli) ]
|
|
62
|
-
- 설치: `npm i -g iosignal-cli` 또는 `sudo npm i -g iosignal-cli`
|
|
63
|
-
- Mac, Linux, Windows 지원.
|
|
64
|
-
- 서버 및 클라이언트
|
|
65
|
-
|
|
66
|
-
- 아두이노 iosignal 라이브러리 및 예시:
|
|
67
|
-
- 아두이노 라이브러리 관리자 사용: `iosignal`
|
|
68
|
-
- 또는 `iosignal-arduino` [ [github](https://github.com/remocons/iosignal-arduino) ]
|
|
69
|
-
- 웹 앱 : http://test.iosignal.net
|
|
70
|
-
|
|
71
|
-
- 아두이노 remocon 라이브러리 및 예시:
|
|
72
|
-
- 아두이노 라이브러리 관리자 사용: `remocon`
|
|
73
|
-
- 또는 `remocon-arduino` [ [github](https://github.com/remocons/remocon-arduino) ]
|
|
74
|
-
- 웹 앱 : https://remocon.kr
|
|
75
|
-
|
|
76
|
-
## 라이선스
|
|
77
|
-
|
|
78
|
-
이 코드는 MIT 라이선스에 따라 배포됩니다.
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* api/RediService.js 테스트
|
|
3
|
-
*
|
|
4
|
-
* 사전준비.
|
|
5
|
-
* localhost 에 redis-server 운영
|
|
6
|
-
* some sample data 저장.
|
|
7
|
-
*/
|
|
8
|
-
import { RedisService, Server , IO } from 'iosignal'
|
|
9
|
-
import { createClient } from 'redis'
|
|
10
|
-
|
|
11
|
-
const redisClient = createClient() // default redis. localhost:6379
|
|
12
|
-
redisClient.connect();
|
|
13
|
-
|
|
14
|
-
redisClient.on('error', (err)=>{
|
|
15
|
-
console.log('redisCleint err: ', err)
|
|
16
|
-
})
|
|
17
|
-
redisClient.on('ready', ()=>{
|
|
18
|
-
console.log('redisClient is ready.')
|
|
19
|
-
})
|
|
20
|
-
redisClient.on('end', ()=>{
|
|
21
|
-
console.log('redisClient is end.')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const server = new Server({port:0, showMessage: 'message'})
|
|
25
|
-
.attach('redis', new RedisService( redisClient , -1))
|
|
26
|
-
|
|
27
|
-
server.on('ready',()=>{
|
|
28
|
-
let io = new IO('ws://localhost:'+server.port)
|
|
29
|
-
io.on('ready', async ()=>{
|
|
30
|
-
console.log('io ready. cid: ', io.cid )
|
|
31
|
-
let apiResult;
|
|
32
|
-
try {
|
|
33
|
-
apiResult = await io.call('redis','hGetAll','device:one')
|
|
34
|
-
console.log(apiResult)
|
|
35
|
-
apiResult = await io.call('redis','HGETALL','device:one')
|
|
36
|
-
console.log(apiResult)
|
|
37
|
-
apiResult = await io.call('redis','save')
|
|
38
|
-
console.log(apiResult)
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.log('io api req err', error)
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
io.on('error',(err)=>{
|
|
44
|
-
console.log('io client error: ', err)
|
|
45
|
-
})
|
|
46
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IO, Server, replyService } from "iosignal"
|
|
3
|
-
|
|
4
|
-
const server = new Server({
|
|
5
|
-
port: 0,
|
|
6
|
-
// showMessage: 'message'
|
|
7
|
-
})
|
|
8
|
-
server.attach('reply', replyService)
|
|
9
|
-
|
|
10
|
-
server.on('ready', () => {
|
|
11
|
-
console.log('server is ready', server.port)
|
|
12
|
-
|
|
13
|
-
const io = new IO('ws://localhost:' + server.port)
|
|
14
|
-
io.on('ready', async () => {
|
|
15
|
-
console.log('ready cid', io.cid)
|
|
16
|
-
|
|
17
|
-
let result;
|
|
18
|
-
try {
|
|
19
|
-
result = await io.call('reply', 'echo', 'hello')
|
|
20
|
-
if (result.ok) console.log('[echo respose] ', result.body)
|
|
21
|
-
|
|
22
|
-
result = await io.call('reply', 'date')
|
|
23
|
-
if (result.ok) console.log('[date respose] ', result.body)
|
|
24
|
-
|
|
25
|
-
result = await io.call('reply', 'unixtime')
|
|
26
|
-
if (result.ok) console.log('[unixtime respose] ', result.body)
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.log('error:', error)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// UNKNOWN_COMMAND ERROR
|
|
32
|
-
try {
|
|
33
|
-
result = await io.call('reply', 'Unknown_command')
|
|
34
|
-
if (result.ok) console.log(result.body)
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.log('error:', error)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
server.close()
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
process.exit();
|
|
42
|
-
}, 1000)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Server , IO, BohoAuth, StringKeyProvider} from 'iosignal'
|
|
2
|
-
|
|
3
|
-
// serverOption.showMetric = 2;
|
|
4
|
-
|
|
5
|
-
const authManager = new BohoAuth( new StringKeyProvider('io.key.io.3,io2.password.io2.3'))
|
|
6
|
-
const s = new Server({
|
|
7
|
-
port: 0,
|
|
8
|
-
// showMetric: 2,
|
|
9
|
-
showMessage: 'message'
|
|
10
|
-
}, authManager);
|
|
11
|
-
// s.attach('sudo', sudoService );
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
15
|
-
|
|
16
|
-
s.on('ready',async ()=>{
|
|
17
|
-
// 서버 listen 포트가 0으로 설정된경우, 자동설정된 값이 s.port 속성으로 확정됨.
|
|
18
|
-
console.log('listening port: ', s.port )
|
|
19
|
-
|
|
20
|
-
let io = new IO('ws://localhost:'+ s.port)
|
|
21
|
-
.on('error',(err)=>{
|
|
22
|
-
console.log(err)
|
|
23
|
-
}).on('change',(name)=>{
|
|
24
|
-
console.log(`<io(${name}:${io.state})`)
|
|
25
|
-
}).on('ready',()=>{
|
|
26
|
-
console.log('#ready cid:', io.cid )
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
let io2 = new IO('ws://localhost:'+ s.port)
|
|
30
|
-
.on('error',(err)=>{
|
|
31
|
-
console.log(err)
|
|
32
|
-
}).on('change',(name)=>{
|
|
33
|
-
console.log(`<io2(${name}:${io2.state})`)
|
|
34
|
-
}).on('ready',()=>{
|
|
35
|
-
console.log('#ready cid:', io2.cid )
|
|
36
|
-
}).on('auth_fail',()=>{
|
|
37
|
-
console.log('#auth_fail: io2')
|
|
38
|
-
}).auth('io2.password')
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
// await delay(2000)
|
|
44
|
-
// process.exit()
|
|
45
|
-
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IO } from 'iosignal'
|
|
3
|
-
const ch_base = 'ch_'
|
|
4
|
-
const url = 'wss://io.remocon.kr/ws'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
시그널 서버 연결된 노드들의 pub/sub 전달 상태 테스트
|
|
9
|
-
|
|
10
|
-
2025. Aug 16.
|
|
11
|
-
여러개의 장치가 하나의 채널을 공유한다.
|
|
12
|
-
하나의 채널당 연결된 node 개수는 nodePerChannel
|
|
13
|
-
총 채널의 개수가 channels
|
|
14
|
-
총 노드수는 channels * nodePerChannel
|
|
15
|
-
|
|
16
|
-
모든 노드가 수신하는 메시지 수를 rCounter 에 누적하고, 1초마다 출력.
|
|
17
|
-
*/
|
|
18
|
-
const channels = 20;
|
|
19
|
-
const nodePerChannel = 5;
|
|
20
|
-
|
|
21
|
-
let remotes = [];
|
|
22
|
-
let rCounter = 0;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for( let j= 0; j < channels ; j++){
|
|
26
|
-
let ch = ch_base + j;
|
|
27
|
-
|
|
28
|
-
console.log( j, ch)
|
|
29
|
-
for(let i = 0; i < nodePerChannel ; i++){
|
|
30
|
-
|
|
31
|
-
let io = new IO(url);
|
|
32
|
-
|
|
33
|
-
let range = 10000; // msec
|
|
34
|
-
let minPeriod = 500; //msec
|
|
35
|
-
let randRange = Math.ceil( Math.random() * range );
|
|
36
|
-
if( i == 0){
|
|
37
|
-
setInterval( ()=>{
|
|
38
|
-
io.signal(ch, 'hello')
|
|
39
|
-
}, minPeriod + randRange)
|
|
40
|
-
}
|
|
41
|
-
io.on('ready',()=>{
|
|
42
|
-
io.subscribe(ch)
|
|
43
|
-
})
|
|
44
|
-
io.on( 'message', (tag, msg )=>{
|
|
45
|
-
rCounter++;
|
|
46
|
-
})
|
|
47
|
-
remotes.push(io)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
console.log('total remotes: ', remotes.length )
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
setInterval( ()=>{
|
|
57
|
-
console.log('rcounter/sec', rCounter )
|
|
58
|
-
rCounter = 0;
|
|
59
|
-
}, 1000)
|
|
60
|
-
|
|
61
|
-
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
unicast using cid
|
|
3
|
-
A,B ready 되면 cidA, cidB에 저장
|
|
4
|
-
A는 B에게, B는 A에게 unicast 1:1 시그널 전송
|
|
5
|
-
|
|
6
|
-
A -> B
|
|
7
|
-
B -> A
|
|
8
|
-
|
|
9
|
-
2. cid 구독, cid 발행
|
|
10
|
-
C는 A의 cid를 구독, C가 cid 발행하면 수신.
|
|
11
|
-
|
|
12
|
-
A cid publish -> C
|
|
13
|
-
|
|
14
|
-
채널 시그널
|
|
15
|
-
유니캐스트 시그널
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
import { Server , IO, MBP , StringKeyProvider, BohoAuth} from 'iosignal'
|
|
20
|
-
const stringKey = 'A.akey.A.3,B.bkey.B.3,C.ckey.C.3'
|
|
21
|
-
const authManager = new BohoAuth(new StringKeyProvider(stringKey) )
|
|
22
|
-
const tag = 'channel'
|
|
23
|
-
const s = new Server({
|
|
24
|
-
port: 0,
|
|
25
|
-
// congPort: 55488,
|
|
26
|
-
// showMessage: 'message'
|
|
27
|
-
}, authManager);
|
|
28
|
-
|
|
29
|
-
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
s.on('ready',async ()=>{
|
|
33
|
-
// 서버 listen 포트가 0으로 설정된경우, 자동설정된 값이 s.port 속성으로 확정됨.
|
|
34
|
-
console.log('listening port: ', s.port )
|
|
35
|
-
|
|
36
|
-
const A = new IO('ws://localhost:'+ s.port)
|
|
37
|
-
A.on('ready', async ()=>{
|
|
38
|
-
console.log('ready A:', A.cid)
|
|
39
|
-
})
|
|
40
|
-
A.on('message',( tag, ...args )=>{
|
|
41
|
-
console.log('[Am]', tag, ...args)
|
|
42
|
-
})
|
|
43
|
-
A.on('@',( tag, ...args )=>{
|
|
44
|
-
console.log('[A@]',tag, ...args)
|
|
45
|
-
}).auth('A.akey')
|
|
46
|
-
|
|
47
|
-
const B = new IO('ws://localhost:'+ s.port)
|
|
48
|
-
.on('ready', async ()=>{
|
|
49
|
-
console.log('ready B:', B.cid)
|
|
50
|
-
B.subscribe('A@news')
|
|
51
|
-
})
|
|
52
|
-
.on('message',( tag, ...args )=>{
|
|
53
|
-
console.log('[Bm]', tag, ...args)
|
|
54
|
-
})
|
|
55
|
-
.on( 'A@news',( tag, ...args )=>{
|
|
56
|
-
console.log('[Bs]', tag, ...args)
|
|
57
|
-
})
|
|
58
|
-
.on('@',( tag, ...args )=>{
|
|
59
|
-
console.log('[B@]', tag, ...args)
|
|
60
|
-
}).auth('B.bkey')
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const C = new IO('ws://localhost:'+ s.port)
|
|
64
|
-
C.on('ready', async ()=>{
|
|
65
|
-
console.log('ready C:', C.cid)
|
|
66
|
-
C.subscribe('A@news')
|
|
67
|
-
})
|
|
68
|
-
C.on( 'A@news',( tag, ...args )=>{
|
|
69
|
-
console.log('[Cs]', tag, ...args)
|
|
70
|
-
})
|
|
71
|
-
C.on('message',( tag, ...args )=>{
|
|
72
|
-
console.log('[Cm]', tag, ...args)
|
|
73
|
-
})
|
|
74
|
-
C.on('@',( tag, ...args )=>{
|
|
75
|
-
console.log('[C@]', tag, ...args)
|
|
76
|
-
}).auth('C.ckey')
|
|
77
|
-
|
|
78
|
-
await delay(200)
|
|
79
|
-
// unicast A -> B@
|
|
80
|
-
A.signal( 'B@', 'A -> B@')
|
|
81
|
-
|
|
82
|
-
// cid_subscribe A -> A@ subscirbers
|
|
83
|
-
A.signal( '@news', 'A -> A@news -> B,C')
|
|
84
|
-
|
|
85
|
-
// unicast B -> A@
|
|
86
|
-
B.signal( 'A@', 'B -> A@')
|
|
87
|
-
|
|
88
|
-
// unicast B -> A@topic
|
|
89
|
-
B.signal( 'A@topic', 'B -> A@topic')
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
await delay(3000)
|
|
93
|
-
process.exit()
|
|
94
|
-
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Server , IO, MBP ,delay } from 'iosignal'
|
|
2
|
-
|
|
3
|
-
const tag = 'ch1'
|
|
4
|
-
const tag2 = 'ch2'
|
|
5
|
-
|
|
6
|
-
const s = new Server({port:0, showMessage: 'message'});
|
|
7
|
-
|
|
8
|
-
s.on('ready',async ()=>{
|
|
9
|
-
// 서버 listen 포트가 0으로 설정된경우, 자동설정된 값이 s.port 속성으로 확정됨.
|
|
10
|
-
console.log('listening port: ', s.port )
|
|
11
|
-
|
|
12
|
-
const io = new IO('ws://localhost:'+ s.port)
|
|
13
|
-
|
|
14
|
-
io.on('message',( tag, ...args )=>{
|
|
15
|
-
console.log('io message: ', tag, ...args)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
io.on('ready',()=>{
|
|
19
|
-
io.subscribe(tag + ',' + tag2 )
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
await delay(1000)
|
|
23
|
-
io.signal(tag, 'text', 'hello')
|
|
24
|
-
io.signal(tag) //empty
|
|
25
|
-
io.signal(tag, 'number', 123)
|
|
26
|
-
io.signal(tag, 'object', {key:'str value', key2: 123 })
|
|
27
|
-
io.signal(tag, 'buffer', Buffer.from('aaaaa'))
|
|
28
|
-
io.signal(tag, 'buffer,str,number', Buffer.from('aaaaa'),'hello', 123)
|
|
29
|
-
let u8 = new Uint8Array(4)
|
|
30
|
-
u8[0] = 1;
|
|
31
|
-
let u32 = new Uint32Array(4)
|
|
32
|
-
u32[0] = 1;
|
|
33
|
-
u32[1] = 2;
|
|
34
|
-
io.signal(tag, 'uit8,uint32', u8, u32 )
|
|
35
|
-
|
|
36
|
-
let mbp = MBP.pack(
|
|
37
|
-
MBP.MB('name8','8', 200),
|
|
38
|
-
MBP.MB('name32', '32', 256 + 200)
|
|
39
|
-
)
|
|
40
|
-
io.signal(tag2 , mbp )
|
|
41
|
-
|
|
42
|
-
io.signal(tag , '1k',Buffer.alloc(1000))
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await delay(3000)
|
|
47
|
-
process.exit()
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {MBP} from 'iosignal'
|
|
2
|
-
|
|
3
|
-
export const Meta = {
|
|
4
|
-
|
|
5
|
-
SERVER_TIME_NONCE: MBP.meta( // 13
|
|
6
|
-
MBP.MB('header','8', 0),
|
|
7
|
-
MBP.MB('unixTime','32L', 0),
|
|
8
|
-
MBP.MB('milTime','32L', 0 ),
|
|
9
|
-
MBP.MB('nonce', Buffer.alloc(4))
|
|
10
|
-
),
|
|
11
|
-
|
|
12
|
-
AUTH_REQ: MBP.meta( // 45
|
|
13
|
-
MBP.MB('header','8', 0),
|
|
14
|
-
MBP.MB('id8',Buffer.alloc(8)),
|
|
15
|
-
MBP.MB('nonce', Buffer.alloc(4)),
|
|
16
|
-
MBP.MB('hmac32', Buffer.alloc(32))
|
|
17
|
-
),
|
|
18
|
-
|
|
19
|
-
AUTH_RES: MBP.meta( // 33
|
|
20
|
-
MBP.MB('header','8', 0),
|
|
21
|
-
MBP.MB('hmac32', Buffer.alloc(32))
|
|
22
|
-
),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ENC_PACK: MBP.meta( //25 + payload
|
|
26
|
-
MBP.MB('type','8',0),
|
|
27
|
-
MBP.MB('len','32L',0), // pure xdata size.
|
|
28
|
-
MBP.MB('salt12', Buffer.alloc(12)), // sec,mil,rand
|
|
29
|
-
MBP.MB('hmac',8,0)
|
|
30
|
-
// MBP.MB( 'xdata', encData )
|
|
31
|
-
),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ENC_488: MBP.meta( // 21 + payload
|
|
35
|
-
MBP.MB('type','8', 0 ),
|
|
36
|
-
MBP.MB('len','32L', 0 ),
|
|
37
|
-
MBP.MB('otpSrc8', Buffer.alloc(8) ),
|
|
38
|
-
MBP.MB('hmac8', Buffer.alloc(8) )
|
|
39
|
-
// MBP.MB('xdata', encData )
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
console.log( Meta.ENC_488 )
|
|
45
|
-
|
|
46
|
-
const MB = MBP.MB;
|
|
47
|
-
|
|
48
|
-
let mbPack = MBP.pack(
|
|
49
|
-
MB('a','8',120),
|
|
50
|
-
MB('b','16',64000),
|
|
51
|
-
MB('c', Buffer.alloc(1000) ),
|
|
52
|
-
MB('c2', 1000, 0) //c와 동일한 역활.
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
let mbObj = MBP.unpack( mbPack)
|
|
56
|
-
let a = mbObj.a
|
|
57
|
-
console.log('a', a)
|
|
58
|
-
|
|
59
|
-
let metaDetail = MBP.getMeta(mbPack ,true)
|
|
60
|
-
|
|
61
|
-
console.log(metaDetail)
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Server , IO, MBP ,delay } from 'iosignal'
|
|
2
|
-
|
|
3
|
-
const tag = 'channel1'
|
|
4
|
-
const s = new Server({
|
|
5
|
-
port:0,
|
|
6
|
-
showMessage: 'message'
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
s.on('ready',async ()=>{
|
|
10
|
-
// 서버 listen 포트가 0으로 설정된경우, 자동설정된 값이 s.port 속성으로 확정됨.
|
|
11
|
-
console.log('listening port: ', s.port )
|
|
12
|
-
|
|
13
|
-
const io = new IO('ws://localhost:'+ s.port)
|
|
14
|
-
io.on('change',(name)=>{
|
|
15
|
-
console.log(`(${name}:${io.state})`)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
io.on('ready',()=>{
|
|
19
|
-
console.log('io is ready. cid:', io.cid )
|
|
20
|
-
io.subscribe(tag)
|
|
21
|
-
io.signal(tag, 'hi')
|
|
22
|
-
})
|
|
23
|
-
io.on('message',( tag, ...args )=>{
|
|
24
|
-
console.log('io message: ', tag, ...args)
|
|
25
|
-
})
|
|
26
|
-
io.listen(tag,( tag, ...args )=>{
|
|
27
|
-
console.log('io listen tag h1: ', tag, ...args)
|
|
28
|
-
})
|
|
29
|
-
io.listen(tag,( tag, ...args )=>{
|
|
30
|
-
console.log('io listen tag h2: ', tag, ...args)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
console.log('listeners', io.listeners( tag ) )
|
|
34
|
-
await delay(200)
|
|
35
|
-
io.signal(tag, 'hello')
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
await delay(1000)
|
|
39
|
-
process.exit()
|
|
40
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Server , IO, MBP } from 'iosignal'
|
|
2
|
-
|
|
3
|
-
const tag = 'aaaaaaaa'
|
|
4
|
-
const s = new Server({
|
|
5
|
-
port:0,
|
|
6
|
-
showMessage: 'message'
|
|
7
|
-
});
|
|
8
|
-
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
9
|
-
|
|
10
|
-
s.on('ready',async ()=>{
|
|
11
|
-
// 서버 listen 포트가 0으로 설정된경우, 자동설정된 값이 s.port 속성으로 확정됨.
|
|
12
|
-
console.log('listening port: ', s.port )
|
|
13
|
-
|
|
14
|
-
const io = new IO('ws://localhost:'+ s.port)
|
|
15
|
-
io.on('change',(name)=>{
|
|
16
|
-
console.log(`(${name}:${io.state})`)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
io.on('ready',()=>{
|
|
20
|
-
console.log('ready cid:', io.cid )
|
|
21
|
-
io.subscribe(tag)
|
|
22
|
-
io.signal(tag, io.cid + ' is ready.')
|
|
23
|
-
})
|
|
24
|
-
io.on('message',( tag, msg )=>{
|
|
25
|
-
console.log('rx tag, message', tag, msg)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
await delay(200)
|
|
30
|
-
io.signal(tag, 'hello')
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
await delay(1000)
|
|
34
|
-
process.exit()
|
|
35
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Server , IO, MBP } from 'iosignal'
|
|
2
|
-
|
|
3
|
-
let mbaPack = MBP.pack(
|
|
4
|
-
MBP.MBA(
|
|
5
|
-
'name', 'hong',
|
|
6
|
-
'age', 33,
|
|
7
|
-
Buffer.alloc(10000),
|
|
8
|
-
Buffer.alloc(10000),
|
|
9
|
-
)
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
let mbaMeta = MBP.getMetaDetail( mbaPack)
|
|
13
|
-
console.log('mbaMeta', mbaMeta )
|
|
14
|
-
// console.log('unpackMba', MBP.unpack( mbaPack ))
|
|
15
|
-
console.log('size', mbaPack.byteLength)
|