iosignal 3.2.0 → 3.3.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.ko.md CHANGED
@@ -1,4 +1,4 @@
1
- [ [English](README.md) | 한국어 ]
1
+ [ [English](./README.md) | 한국어 ]
2
2
 
3
3
 
4
4
  # IOSignal
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [ English | [한국어](README.ko.md) ]
1
+ [ English | [한국어](./README.ko.md) ]
2
2
 
3
3
  # IOSignal
4
4
 
@@ -525,230 +525,6 @@ Fri, 09 Feb 2024 14:24:37 GMT
525
525
  ```
526
526
 
527
527
 
528
- ## Features
529
-
530
- ### Built-in Message Trasport Protocol
531
- - pub/sub multicast by channel name.
532
- - uni-cast: one to one messaging by CID.
533
- - `CID` is a Communication Id
534
- - CID subscribing: subscribe one peer using CID.
535
- - HomeChannel: group by IP address.
536
-
537
- ### Built-in Security
538
- - Authentication
539
- - Encryption
540
- - E2EE
541
- - thanks to the `Boho` [ [github](https://github.com/remocons/boho) ]
542
-
543
- ## Connection
544
- - Web browser use WebSocket.
545
- - Node.js use WebSocket or CongSocket.
546
- - Arduino use CongSocket.
547
-
548
- ## IOSignal Server Architecture
549
- ![IOSignal](./docs/iosignal_architecture.png)
550
-
551
- ## IOSignal repositories.
552
-
553
- - Javascript: `iosignal` [ [github](https://github.com/remocons/iosignal) | [npm](https://www.npmjs.com/package/iosignal) ]
554
- - Node.js server ( WebSocket, CongSocket)
555
- - Node.js client ( WebSocket, CongSocket)
556
- - Web Browser client( WebSocket)
557
-
558
- - CLI program
559
- - `iosignal-cli` [ [github](https://github.com/remocons/iosignal-cli) | [npm](https://www.npmjs.com/package/iosignal-cli) ]
560
- - install: `npm i -g iosignal-cli` or `sudo npm i -g iosignal-cli`
561
- - support mac, linux and windows.
562
- - server and client
563
-
564
- - Arduino iosignal library and examples:
565
- - use Arduino Library Manager: `iosignal`
566
- - or `iosignal-arduino` [ [github](https://github.com/remocons/iosignal-arduino) ]
567
- - web app : http://test.iosignal.net
568
-
569
- - Arduino remocon library and examples:
570
- - use Arduino Library Manager: `remocon`
571
- - or `remocon-arduino` [ [github](https://github.com/remocons/remocon-arduino) ]
572
- - web app : https://remocon.kr
573
-
574
-
575
-
576
- ### Browser client : ESM
577
-
578
- - local file: "dist/io.js"
579
- - CDN: https://cdn.jsdelivr.net/npm/iosignal/dist/io.js
580
-
581
- ```html
582
- <html>
583
-
584
- <script type="module">
585
- import IO from "../dist/io.js"
586
-
587
- const io = new IO('wss://io.iosignal.net/ws')
588
- io.listen('channel#topic', (...args)={
589
- console.log( args )
590
- })
591
-
592
- io.on('ready',()=>{
593
- console.log('ready cid:', io.cid )
594
- })
595
-
596
- </script>
597
-
598
- </html>
599
- ```
600
-
601
-
602
- ### Browser Client : UMD(IIFE)
603
- - local file: "dist/io.min.js"
604
- - CDN: https://cdn.jsdelivr.net/npm/iosignal/dist/io.min.js
605
-
606
- ```html
607
- <html>
608
- <script src="../dist/io.min.js"></script>
609
- <script>
610
- console.log('IO', IO) // default global variable name is IO
611
-
612
- var io1 = new IO('ws://localhost:7777')
613
- var io2 = new IO('ws://localhost:7777')
614
- var io3 = new IO('ws://localhost:7777')
615
-
616
- io1.on('error', errorHandler )
617
- io2.on('error', errorHandler )
618
- io3.on('error', errorHandler )
619
-
620
- let channelName = 'io'
621
-
622
- // classic style subsribing
623
- io1.on('ready',e=>{
624
- io1.subscribe(channelName)
625
- io1.on(channelName, (...args)=>{
626
- // console.log('io1 received', args )
627
- let msg = '[io1] ' + JSON.stringify( args )
628
- addMessage(msg)
629
- })
630
- })
631
-
632
- // iosignal style subscribing
633
- io2.listen(channelName, (...args)=>{
634
- // console.log('io2 receive', args )
635
- let msg = '[io2] ' + JSON.stringify( args )
636
- addMessage(msg)
637
- })
638
-
639
- setInterval(e=>{
640
- io3.signal(channelName, 'single string') // single string payload
641
- io3.signal(channelName, Date.now(), 'a', 2 , {key: 3} ) //multiple payload
642
- io3.signal(channelName ) // pure signal without payload.
643
- },3000)
644
-
645
- function addMessage(msg){
646
- // ...
647
- }
648
-
649
- function errorHandler(e){
650
- // ...
651
- }
652
- </script>
653
-
654
- </html>
655
- ```
656
-
657
-
658
-
659
-
660
- ### NodeJS Client
661
- ```js
662
- import { IO } from "iosignal"
663
-
664
- const io = new IO('wss://io.iosignal.net/ws')
665
-
666
- io.on('ready', ()=>{
667
- console.log('ready cid:', io.cid)
668
- io.signal('#screen','playToggle')
669
- });
670
-
671
- io.listen('#notify', (...args)=>{
672
- console.log( args )
673
- })
674
-
675
- io.on('error',err=>{
676
- console.log('err', err)
677
- })
678
-
679
- ```
680
-
681
-
682
-
683
-
684
- ## IOSignal Server
685
-
686
-
687
- ```js
688
- import { Server } from "iosignal"
689
-
690
- const server = new Server(
691
- {
692
- port: 7777,
693
- congPort: 8888,
694
- showMetric: 2,
695
- showMessage: 'message' // show signal message
696
- })
697
-
698
- ```
699
-
700
- - port: <Number> IOSignal over WebSocket
701
- - congPort: <Number> IOsignal over CongSocket
702
- - showMetric: 1|2|3 show clients cid(state) info
703
- - showMessage: "none"|"message" show signal buffer message
704
- - timeout <milliseconds> ping period & timeout (min. 1000)
705
-
706
- ### IOSignal API
707
-
708
- IOSignal API examples
709
- - src/api_reply.js // 'echo', 'date', 'unixtime'
710
- - src/api_sudo.js // server admin monitoring command
711
- - src/RedisAPI.js // redis command and response service
712
-
713
-
714
- To register an API service with the server, use the api() method
715
-
716
- `api('api_name', module )`
717
-
718
- ```js
719
- // node.js
720
- import { Server ,api_reply } from 'iosignal'
721
- const server = new Server( { port: 7777 } )
722
- server.api('reply', api_reply) // attach api module
723
- ```
724
-
725
- Example of a client calling the reply API
726
-
727
- ```js
728
- // web browser api client example
729
- <script src="../dist/io.min.js"></script>
730
- <script>
731
- const io = new IO('ws://localhost:7777')
732
-
733
- io.on('ready', async ()=>{
734
- let res_echo = await io.req('reply', 'echo', 'hello' )
735
- let res_date = await io.req('reply', 'date' )
736
- let res_unixtime = await io.req('reply', 'unixtime' )
737
-
738
- if( res_echo.ok ) console.log( res_echo.body )
739
- if( res_date.ok ) console.log( res_date.body )
740
- if( res_unixtime.ok ) console.log( res_unixtime.body )
741
- });
742
- </script>
743
-
744
- // result
745
- [ 'hello' ]
746
- Fri, 09 Feb 2024 14:24:37 GMT
747
- 1707488677
748
-
749
- ```
750
-
751
-
752
528
  ## Features
753
529
 
754
530
  ### Built-in Message Trasport Protocol
package/dist/io.d.ts CHANGED
@@ -211,6 +211,8 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
211
211
  * @param {Buffer} buffer - The incoming data buffer.
212
212
  */
213
213
  onData(buffer: Buffer$1): void;
214
+ did: any;
215
+ uid: any;
214
216
  /**
215
217
  * Sends an IAM (I Am) message to the server.
216
218
  * @param {string} [title] - Optional title for the IAM message.
@@ -302,9 +304,9 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
302
304
  */
303
305
  get(storeName: string): Promise<any>;
304
306
  /**
305
- * Sends a request to a target and topic.
306
- * @param {string} target - The target of the request.
307
- * @param {string} topic - The topic of the request.
307
+ * Sends a request to a target and topic.(remote api call)
308
+ * @param {string} target - The target(api name) of the request.
309
+ * @param {string} topic - The topic(api function name) of the request.
308
310
  * @param {...any} args - Optional arguments for the request.
309
311
  * @returns {Promise<any>}
310
312
  */