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

resmetry

v1.0.9

Published

A library supporting request-response operation over MQTT

Downloads

2

Readme

Resmetry is a client library for the MQTT protocol, written in JavaScript for node.js with the aim of building request-response communication on top of mqtt protocol. Resmetry supports both on request connection and always-on connection.

This library relies on MQTT.js library for interacting with mqtt server.

Installation

npm install resmetry --save

Example

var resmetrylib=require('resmetry');
var host='mqtt://localhost';
//Standard settings available in npm package mqtt
var settings={
  protocolId: 'MQIsdp',
  protocolVersion: 3
};
/**
 * The last parameter should be true for an always active connection, false for a one time connection
 * @type {resmetry}
 */
var resmetry= new resmetrylib(host,settings,false);

/*
* Get mqtt client for advanced operations, Refer npm package mqtt for more information
* For other features offered by MQTT, the modifications can be made using the object
* Only applicable true is passed the last parameter of the constructor
*/
//var mqtt=resmetry.getMQTTClient();
//MQTT operations
//mqtt.subscribe('request/1');

//Connection listener
resmetry.on('connect',function(message){
  console.log(message);
});

//Message event listener
var temp=25;
resmetry.on('message',function(topic,message){
  console.log("Topic: "+topic,"Message: "+message);
  if(topic==='request/1'&&message==='temp'){
    mqtt.publish('response/1',temp+'',{qos:2});
  }
});

//Making a request to topic 'request' with message 'send me details' whose expected result goes to topic response with options
var options={qos:2};
//Options are standard options available for publishing in npm package mqtt
resmetry.request('request/1','temp',options,'response/1',function(err,response){
  console.log('Response:'+response);
});

output:

Connected
Topic: request/1 Message: temp
Topic: response/1 Message: 25
Response:25

## API

  • new resmetry()
  • resmetry.request()
  • resmetry.getMQTTClient()
  • resmetry.disconnect()

new resmetry(host,settings,connectionType)

Connects to the broker specified by the given url and options and ted options. Options are as mentioned in connect part of npm package mqtt.js ConnectionType specifies whether current operation is one-time or continuous. One-time activated by passing false, makes the connection end after obtaining the response. Whereas, continuous operation mode activated by passing true, runs forever.


resmetry.request(topic,data,options,responseTopic,callback)

  • 'topic' is the topic to which message will be send to.[Like request]
  • 'data' is the message which needs to be passed along with request
  • 'options' are additional options like qos and retain features. Refer npm package mqtt.js publish
  • 'responseTopic' is the the topic to which response will be send to[Like response]
  • 'callback' is where any err or result will be passed

resmetry.getMQTTClient()

Returns the mqtt client for the functionality of add your listeners other than 'message' event.Refer mqtt.js Events for information on events and other functionalities.


resmetry.disconnect()

Disconnects the active MQTT client connection


## Events

  • connect
  • message
  • error

resmetry.on('connect',function(message))

  • Fired when mqtt client connects to server
  • 'message' is a string saying Connected

resmetry.on('message',function(topic,message))

  • Fired when a message comes
  • 'topic' is the topic to which message was published
  • 'message' contains the message send in the topic

resmetry.on('error',function(error))

  • Fired when error is encountered
  • error contains details related to the error thrown

License

MIT