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

@mangar2/broker

v1.4.0

Published

implements a 'mqtt type' http server

Downloads

2

Readme

Abstract

The ( mqtt ) broker is a central service receiving and distributing messages to all subscribed receipiens . Use the "brokerservice" module to start the broker .

Contents

Meta

| | | | --- | --- | | File | broker.js | | Abstract | The ( mqtt ) broker is a central service receiving and distributing messages to all subscribed receipiens . Use the "brokerservice" module to start the broker . | | Author | Volker Böhm | | Copyright | Copyright ( c ) 2020 Volker Böhm | | License | This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 . It is furnished "as is" , without any support , and with no warranty , express or implied , as to its usefulness for any purpose . |

Class Broker

new Broker(configuration)

Creates a new broker

Example

const configuration = {
     port: 10000,
     persistInterval: 0,
     connections: {
          directory: '.',
          fileName: 'broker',
          log: [
              {
                  module: 'received',
                  topic: '#'
              }
          ]
      }
  }
const broker = new Broker(configuration)
broker.run()

Broker Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | configuration | Object | configuration for the broker | |

configuration properties

| Name | Type | Attribute | Default | Description | | ---------- | ------------ | ------------ | ------------ | ----------------- | | port | number, string | | | port number the broker will listen on | | | persistInterval | number | optional | 60 * 1000 | Intervall between persisting internal state to file in milliseconds . Persistance is not called if this value is 0 | | | connections | Object | | | connection settings for the broker | |

connections properties

| Name | Type | Attribute | Default | Description | | ---------- | ------------ | ------------ | ------------ | ----------------- | | fileName | string | | | filename for persistence | | | directory | string | | | directory ( file path ) for persistence | | | replyTimeoutInMilliseconds | number | | | timeout to wait for an answer of a http call | | | inFlightWindow | number | optional | 1 | amount of qos 1 and qos 2 messages send for the same topic at the same time | | | pubrelTimeoutInMilliseconds | number | optional | one day | temeout to wait for a corresponding pubrel message | | | maxRetryCount | number | | | amount of resend of messages before forcing a disconnect | | | maxQueuSize | number | | | maximal amount of entries in a message queue | | | log | Object | | | log settings | |

Broker Methods

close

async close ()

Closes the broker , stops listening

connect

connect (host, port)

Connects to a friendly broker and subscribs for all messages

connect Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | host | string | name of the host ( or his ip ) | | | port | number | port number to connect to | |

on

on (event, callback)

Sets a callback .

on Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | event | string | callback name ( supports 'send' and 'publish' ) 'send' is called to send data . This function is provided by the broker but could be overwritten 'publish' is called on receiving data . This function if provided by the broker but could be overwritten | | | callback | function | | |

on throws

| Type | Description | | ---- | ----------- | | Error | if the event is not supported | | Error | if the callback is not 'function' |

run

run ()

Starts the broker . It will listen to message , send messages and periodically store its status