iosignal 1.8.0 → 2.0.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/LICENSE +1 -1
- package/README.md +39 -40
- package/dist/iosignal.cjs +25 -1
- package/dist/iosignal.iife.js +26 -0
- package/dist/iosignal.iife.js.map +1 -0
- package/dist/iosignal.js +19 -4
- package/dist/iosignal.js.map +1 -1
- package/index.js +6 -2
- package/package.json +4 -8
- package/rollup.config.js +10 -37
- package/src/auth/Auth_Env.js +2 -2
- package/src/auth/Auth_File.js +2 -2
- package/src/auth/Auth_Redis.js +2 -2
- package/src/auth/BohoAuth.js +5 -5
- package/src/client/CongPacket.js +1 -1
- package/src/client/IOCore.js +12 -11
- package/src/client/IOWebSocket.js +9 -4
- package/src/common/payload.js +1 -1
- package/src/server/Manager.js +1 -1
- package/src/server/RemoteCore.js +13 -13
- package/test-browser/index.html +8 -8
- package/test-client-nodejs/client.cjs +2 -2
- package/test-client-nodejs/client.mjs +2 -2
- package/test-client-nodejs/client_api_reply.mjs +2 -2
- package/test-client-nodejs/stateChange.mjs +2 -2
- package/test-signal-payloadType/signaling.js +3 -3
- package/dist/iosignal-iife.js +0 -11
- package/dist/iosignal-iife.js.map +0 -1
- package/indexWebBrowser.js +0 -13
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022 Taeo
|
|
3
|
+
Copyright (c) 2022 Lee Taeo <taeo.mocha@gmail.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -15,24 +15,20 @@ The signaling protocol is built-in, so the server can be used without programmin
|
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
18
|
-
```
|
|
18
|
+
```shell
|
|
19
19
|
$ npm i iosignal
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## IOSignal Server
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### ESM style
|
|
27
|
-
|
|
28
|
-
```
|
|
24
|
+
### ESM
|
|
25
|
+
```js
|
|
29
26
|
import { Server } from "iosignal"
|
|
30
27
|
const server = new Server( { port: 7777 } )
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
### CJS
|
|
34
|
-
|
|
35
|
-
```
|
|
30
|
+
### CJS
|
|
31
|
+
```js
|
|
36
32
|
let { Server } = require('iosignal')
|
|
37
33
|
const server = new Server( { port: 7777 } )
|
|
38
34
|
```
|
|
@@ -59,7 +55,7 @@ const server = new Server(
|
|
|
59
55
|
- showMessage: "none"|"message" show signal buffer message
|
|
60
56
|
- timeout <milliseconds> ping period & timeout (min. 1000)
|
|
61
57
|
|
|
62
|
-
###
|
|
58
|
+
### IOSignal API
|
|
63
59
|
|
|
64
60
|
IOSignal API examples
|
|
65
61
|
- src/api_reply.js // 'echo', 'date', 'unixtime'
|
|
@@ -72,6 +68,7 @@ To register an API service with the server, use the api() method
|
|
|
72
68
|
`api('api_name', module )`
|
|
73
69
|
|
|
74
70
|
```js
|
|
71
|
+
// node.js
|
|
75
72
|
import { Server ,api_reply } from 'iosignal'
|
|
76
73
|
const server = new Server( { port: 7777 } )
|
|
77
74
|
server.api('reply', api_reply) // attach api module
|
|
@@ -80,19 +77,21 @@ server.api('reply', api_reply) // attach api module
|
|
|
80
77
|
Example of a client calling the reply API
|
|
81
78
|
|
|
82
79
|
```js
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
io
|
|
87
|
-
let res_echo = await io.req('reply', 'echo', 'hello' )
|
|
88
|
-
let res_date = await io.req('reply', 'date' )
|
|
89
|
-
let res_unixtime = await io.req('reply', 'unixtime' )
|
|
80
|
+
// web browser example
|
|
81
|
+
<script src="../dist/iosignal.iife.js"></script>
|
|
82
|
+
<script>
|
|
83
|
+
const io = new IO('ws://localhost:7777')
|
|
90
84
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
io.on('ready', async ()=>{
|
|
86
|
+
let res_echo = await io.req('reply', 'echo', 'hello' )
|
|
87
|
+
let res_date = await io.req('reply', 'date' )
|
|
88
|
+
let res_unixtime = await io.req('reply', 'unixtime' )
|
|
94
89
|
|
|
95
|
-
|
|
90
|
+
if( res_echo.ok ) console.log( res_echo.body )
|
|
91
|
+
if( res_date.ok ) console.log( res_date.body )
|
|
92
|
+
if( res_unixtime.ok ) console.log( res_unixtime.body )
|
|
93
|
+
});
|
|
94
|
+
</script>
|
|
96
95
|
|
|
97
96
|
// result
|
|
98
97
|
[ 'hello' ]
|
|
@@ -105,27 +104,27 @@ Fri, 09 Feb 2024 14:24:37 GMT
|
|
|
105
104
|
## IOSignal Client
|
|
106
105
|
|
|
107
106
|
### NodeJS Client
|
|
108
|
-
```
|
|
109
|
-
// ESM
|
|
110
|
-
import {
|
|
107
|
+
```js
|
|
108
|
+
// ESM
|
|
109
|
+
import { IOWS } from "iosignal"
|
|
111
110
|
|
|
112
|
-
// CJS
|
|
113
|
-
// const {
|
|
111
|
+
// CJS
|
|
112
|
+
// const { IOWS } = require('iosignal')
|
|
114
113
|
|
|
115
|
-
const io = new
|
|
114
|
+
const io = new IOWS('wss://io.iosignal.net/ws')
|
|
116
115
|
|
|
117
|
-
io.on('ready', ()=>{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
116
|
+
io.on('ready', ()=>{
|
|
117
|
+
console.log('ready cid:', io.cid)
|
|
118
|
+
io.signal('#screen','playToggle')
|
|
119
|
+
});
|
|
121
120
|
|
|
122
|
-
io.listen('#notify', (...args)=>{
|
|
123
|
-
|
|
124
|
-
})
|
|
121
|
+
io.listen('#notify', (...args)=>{
|
|
122
|
+
console.log( args )
|
|
123
|
+
})
|
|
125
124
|
|
|
126
|
-
io.on('error',err=>{
|
|
127
|
-
|
|
128
|
-
})
|
|
125
|
+
io.on('error',err=>{
|
|
126
|
+
console.log('err', err)
|
|
127
|
+
})
|
|
129
128
|
|
|
130
129
|
```
|
|
131
130
|
|
|
@@ -134,7 +133,7 @@ io.on('error',err=>{
|
|
|
134
133
|
```html
|
|
135
134
|
<html>
|
|
136
135
|
|
|
137
|
-
<script src="../dist/iosignal
|
|
136
|
+
<script src="../dist/iosignal.iife.js"></script>
|
|
138
137
|
|
|
139
138
|
<script>
|
|
140
139
|
console.log('IO', IO) // default global variable name is IO
|
|
@@ -189,9 +188,9 @@ io.on('error',err=>{
|
|
|
189
188
|
<html>
|
|
190
189
|
|
|
191
190
|
<script type="module">
|
|
192
|
-
import
|
|
191
|
+
import IO from "../dist/iosignal.js"
|
|
193
192
|
|
|
194
|
-
const
|
|
193
|
+
const io = new IO('wss://io.iosignal.net/ws')
|
|
195
194
|
io.listen('channel#topic', (...args)={
|
|
196
195
|
console.log( args )
|
|
197
196
|
})
|