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/mqttservice

v1.2.1

Published

communicates with a MQTT-Style HTTP broker

Downloads

14

Readme

Abstract

Library module to communicate with the mqtt broker . It includes Publish to send messsages to the broker and OnPublish to receive messages published by the broker

Contents

Meta

| | | | --- | --- | | File | mqttservice.js | | Abstract | Library module to communicate with the mqtt broker . It includes Publish to send messsages to the broker and OnPublish to receive messages published by 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 . |

Callback definitions

ProcessMessage

ProcessMessage Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | message | Object | the message received | | | qos | 0, 1, 2 | the quality of service information | | | dup | 0, 1 | flag signaling duplicates | |

Class OnPublish

new OnPublish(listenerPort, logSettings, qos2PubrelTimeoutInSeconds)

Creates a new server receiving messages Supports registering a callback with on ( 'publish' , ( payload , qos ) = > { } ) called for each received message

OnPublish Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | listenerPort | number | port to listen on | | | logSettings | Object | logging settings | | | qos2PubrelTimeoutInSeconds | number | time to delete qos2 related packageid´s from the qos2 queue . This will happen , if a pubrel does not follow the publish call for a this amount of seconds | |

OnPublish Members

| Name | Type | description | | ------------ | ------------ | ------------ | | logFilter | LogFilter | Logging filter | | port | number | Port the server uses , only defined after listen has been called ! |

OnPublish Methods

close

close ()

Closes all connections

listen

listen ()

Starts to listen and wait for input

on

on (event, callback)

Sets a callback . Usually , there is no need to set anything here

on Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | event | string | event name , supported 'publish' | | | callback | ProcessMessage | callback to be called , to process messages received | |

Class PublishMessage

new PublishMessage(host, port, configuration)

Creates a client for publishing messages

Example

//Publish the message with topic /a/a, value 1, reason "test", QoS 0, retain 0:
const publish = new PublishMessage('myhost', 10000, { retry: 60 })
result = await publish.publish(publishtoken, new Message("/a/a", 1, "test"), 0, 0);

PublishMessage Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | host | string | host name ( or ip ) | | | port | number | port number | | | configuration | Object | configuration options | |

configuration properties

| Name | Type | Attribute | Default | Description | | ---------- | ------------ | ------------ | ------------ | ----------------- | | retry | number | optional | 60 | amount of retries to send a message | |

PublishMessage Methods

close

async close ()

Closes the connection to the broker

publish

async publish (token, message, qos, retain, version)

Publishes a message with a defined quality of service automatically generating an id

publish Parameters

| Name | Type | Description | | ---------- | ------------ | ----------------- | | token | string | connection token | | | message | Object | message to publish . | | | qos | number | 0 , 1 , 2 quality of service | | | retain | boolean | True , if message shall be retained for future subscriptions | | | version | string, undefined | interface version , supports 0 . 0 and 1 . 0 ( default ) | |

publish throws

| Type | Description | | ---- | ----------- | | string | on any connection error |