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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Taeo Lee <taeo.mocha@gmail.com>
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
- CommonJS and ESM support both
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 style
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
- ### IOSiognal API
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
- import { IO } from "iosignal"
84
- const io = new IO('ws://localhost:7777')
85
-
86
- io.on('ready', async ()=>{
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
- if( res_echo.ok ) console.log( res_echo.body )
92
- if( res_date.ok ) console.log( res_date.body )
93
- if( res_unixtime.ok ) console.log( res_unixtime.body )
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 { IO } from "iosignal"
107
+ ```js
108
+ // ESM
109
+ import { IOWS } from "iosignal"
111
110
 
112
- // CJS
113
- // const { IO } = require('iosignal')
111
+ // CJS
112
+ // const { IOWS } = require('iosignal')
114
113
 
115
- const io = new IO('wss://io.iosignal.net/ws')
114
+ const io = new IOWS('wss://io.iosignal.net/ws')
116
115
 
117
- io.on('ready', ()=>{
118
- console.log('ready cid:', io.cid)
119
- io.signal('#screen','playToggle')
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
- console.log( args )
124
- })
121
+ io.listen('#notify', (...args)=>{
122
+ console.log( args )
123
+ })
125
124
 
126
- io.on('error',err=>{
127
- console.log('err', err)
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-iife.js"></script>
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 { IO, Boho, MBP, Buffer } from "../dist/iosignal.js"
191
+ import IO from "../dist/iosignal.js"
193
192
 
194
- const = io = new IO('wss://io.iosignal.net/ws')
193
+ const io = new IO('wss://io.iosignal.net/ws')
195
194
  io.listen('channel#topic', (...args)={
196
195
  console.log( args )
197
196
  })