npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iosignal

v2.2.0

Published

iosignal

Downloads

34

Readme

IOSignal

[En] iosignal supports real-time communication between web browsers, node.js, and arduino. It also provides secure authentication and encrypted communication. The signaling protocol is built-in, so the server can be used without programming.

[Kr] iosignal 은 웹브라우저, node.js , arduino 간의 실시간 통신을 지원합니다. 또한 보안 인증과 암호통신 기능도 제공됩니다. 시그널링 프로토콜이 내장되어 있어서 서버는 프로그래밍 없이 사용 가능합니다.

Install

$ npm i iosignal

IOSignal Server

ESM

import { Server } from "iosignal"
const server = new Server( { port: 7777 } )

CJS

let { Server } = require('iosignal')
const server = new Server( { port: 7777 } )

server options

let { Server } = require('iosignal')

const server = new Server(
  {
    port: 7777,     
    congPort: 8888, 
    showMetric: 2,  
    showMessage: 'message' // show signal message
  })
  • port: IOSignal over WebSocket
  • congPort: IOsignal over CongSocket
  • showMetric: 1|2|3 show clients cid(state) info
  • showMessage: "none"|"message" show signal buffer message
  • timeout ping period & timeout (min. 1000)

IOSignal API

IOSignal API examples

  • src/api_reply.js // 'echo', 'date', 'unixtime'
  • src/api_sudo.js // server admin monitoring command
  • src/RedisAPI.js // redis command and response service

To register an API service with the server, use the api() method

api('api_name', module )

// node.js
import { Server ,api_reply  } from 'iosignal'
const server = new Server( { port: 7777 }  )
server.api('reply', api_reply) // attach api module

Example of a client calling the reply API

  // web browser api client example
  <script src="../dist/io.min.js"></script>
  <script>
      const io = new IO('ws://localhost:7777')

      io.on('ready', async ()=>{
        let res_echo = await io.req('reply', 'echo', 'hello' )
        let res_date = await io.req('reply', 'date' )
        let res_unixtime = await io.req('reply', 'unixtime' )

        if( res_echo.ok ) console.log( res_echo.body  )
        if( res_date.ok ) console.log( res_date.body  )
        if( res_unixtime.ok ) console.log( res_unixtime.body  )
      });
  </script>

// result
[ 'hello' ]
Fri, 09 Feb 2024 14:24:37 GMT
1707488677

IOSignal Client

NodeJS Client

  // ESM
  import { IO } from "iosignal"

  // CJS
  // const { IO } = require('iosignal')

  const io = new IO('wss://io.iosignal.net/ws')

  io.on('ready', ()=>{
    console.log('ready cid:', io.cid)
    io.signal('#screen','playToggle')
  });

  io.listen('#notify', (...args)=>{
    console.log( args )
  })

  io.on('error',err=>{
      console.log('err', err)
  })

Browser Client : UMD(IIFE)

  • local file: "./dist/io.min.js"
  • CDN: https://cdn.jsdelivr.net/npm/[email protected]/dist/io.min.js
<html>
  <script src="../dist/io.min.js"></script>
  <script>
    console.log('IO', IO)  // default global variable name is IO

    var io1 = new IO('ws://localhost:7777')
    var io2 = new IO('ws://localhost:7777')
    var io3 = new IO('ws://localhost:7777')

    io1.on('error', errorHandler )
    io2.on('error', errorHandler )
    io3.on('error', errorHandler )

    let channelName = 'io'

    // classic style subsribing
    io1.on('ready',e=>{
      io1.subscribe(channelName)
      io1.on(channelName, (...args)=>{
        // console.log('io1 received', args )
        let msg = '[io1] ' + JSON.stringify( args )
        addMessage(msg)
      })
    })

    // iosignal style subscribing
    io2.listen(channelName, (...args)=>{
      // console.log('io2 receive', args )
      let msg = '[io2] ' + JSON.stringify( args )
        addMessage(msg)
    })

    setInterval(e=>{
      io3.signal(channelName, 'single string')   // single string payload
      io3.signal(channelName, Date.now(), 'a', 2 , {key: 3} ) //multiple payload 
      io3.signal(channelName ) // pure signal without payload.
    },3000)

    function addMessage(msg){
      // ...
    }

    function errorHandler(e){
      // ...
    }
  </script>

</html>

Browser client : ESM

<html>

  <script type="module">
    import IO from "../dist/io.js"

    const io = new IO('wss://io.iosignal.net/ws')
    io.listen('channel#topic', (...args)={
      console.log( args )
    })

    io.on('ready',()=>{
      console.log('ready cid:', io.cid )
    })

  </script>

</html>

Features

Built-in Message Trasport Protocol

  • pub/sub multicast by channel name.
  • uni-cast: one to one messaging by CID.
  • CID is a Communication Id
  • CID subscribing: subscribe one peer using CID.
  • HomeChannel: group by IP address.

Built-in Security

  • Authentication
  • Encryption
  • E2EE
  • thanks to the Boho [ github ]

Connection

  • Web browser use WebSocket.
  • Node.js use WebSocket or CongSocket.
  • Arduino use CongSocket.

IOSignal

IOSignal repositories.

  • Javascript: iosignal [ github | npm ]

    • Node.js server ( WebSocket, CongSocket)
    • Node.js client ( WebSocket, CongSocket)
    • Web Browser client( WebSocket)
  • CLI program

    • iosignal-cli [ github | npm ]
    • install: npm i -g iosignal-cli or sudo npm i -g iosignal-cli
    • support mac, linux and windows.
    • server and client
  • Arduino iosignal library and examples:

    • use Arduino Library Manager: iosignal
    • or iosignal-arduino [ github ]
    • web app : http://test.iosignal.net
  • Arduino remocon library and examples:

    • use Arduino Library Manager: remocon
    • or remocon-arduino [ github ]
    • web app : https://remocon.kr

License

This code is released under the MIT License.