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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fpm-plugin-socket

v1.1.1

Published

FPM socket plugin

Readme

fpm-plugin-socket

A plugin for Socket, It's only for a few datas( Normally < 20 bytes ).

We use it to build IOT project.

Transform with byte array like hex.

~Support CRC16 data compare.~

Basic Info

  • Run Action Hook Name: BEFORE_SERVER_START
  • ExtendModule Name: socket
  • Exception
    • [x] Nope
  • getDependencies()
    • [x] []
  • The Reference Of The Bind() Method An BizModule Object Contains those Functions
    • [ ] broadcast
    • [ ] send
    • [ ] getOnlineDevice
    • [ ] isOnline

Usage

  • SetEncoder/SetDecoder

    • setDataDecoder it must be return a Object{id, data}, and some crc16 compare, return undefined if crc16 error

      socketServer.setDataDecoder((src) => {
        // the last 2 bytes is the crc16 data
        let data = _.dropRight(src, 2)
        data = Buffer.from(data, 'hex')
      
        let id = Buffer.from(_.take(data, 2), 'hex').toString('hex')
        return {id, data}
      })
    • setDataEncoder

      Make sure return an Buffer Object

  • Broadcast message

    fpm.execute('socket.broadcast', message!Object, channel?Array, ids?Array) => Array

    • it always return a resolved Promise with the counter of success broadcast messages
  • Send message to The client

    fpm.execute('socket.send', id!String, message!HexString) => Promise

    • it return an reject if send error
  • Add channel for clients

    fpm.execute('socket.addChannel', channel!String, ids!Array) => Array

    • it return an array of addChannel success ok.
  • getOnlineDevice

    fpm.execute('socket.getOnlineDevice', message!Object) => Object

    • it returns the online devices
  • isOnline

    fpm.execute('socket.isOnline', id!String) => Number!0/1

    • it returns 1 which use the id is online
  • getClient

    fpm.execute('socket.getClient', id!String) => SocketClient

    • it returns socketClient of the online device with id
  • Subscribe Event To Receive Message

    • [ ] ##socket/receive
      fpm.subscribe('#socket/receive', (topic, message) => {
      	console.info(message)
      })
    • [ ] #socket/connect
      fpm.subscribe('#socket/connect', (topic, message) => {
      	console.info(message);

    }) /* { id: '0102', ip: '127.0.0.1', port: 41510, channel: [], tag: 'UN_TAGED', alias: 'UN_ALIAS', extend: {} } */

    - [ ] `#socket/decode/error`
    ```javascript
    fpm.subscribe('#socket/decode/error', (topic, data) => {
    	console.info(data)
    })
    • [ ] #socket/close
      fpm.subscribe('#socket/close', (topic, client) => {
      	console.info(client)
      })
    • [ ] #socket/error
      fpm.subscribe('#socket/error', (topic, error) => {
      	console.info(error)
      })