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 🙏

© 2026 – Pkg Stats / Ryan Hefner

proto-mqtt-client

v0.1.8

Published

A client-sided library to simulate sensors linked to a proto-mqtt broker.

Readme

proto-mqtt client

The proto-mqtt client is a wrapper for MQTT.js for easy interfacing with the proto-mqtt broker.

NPM

Use proto-mqtt client in your Node project

To use the proto-mqtt-client as a dependency in your project, put yourself in the project folder, and then execute the following :

npm install --save proto-mqtt-client

Use proto-mqtt client in a browser-sided project

In order to convert the Node JS library to a browser library, you'll need to install browserify :

npm install -g browserify

Then clone the source, build it, and then browserify it where you want :

git clone https://github.com/Nolyurn/proto-mqtt
cd proto-mqtt/api
npm install
npm build
browserify dist/index.js -o bundle.js

And your bundle.js file is now ready to be used in your client-sided applications.

Usage

Belonging to your privileges, you can use three different classes : one for each privilege. To connect to the broker, whatever is the class, the procedure is the same :

import {Client} from 'proto-mqtt-client'

let client = new Client("<proto-mqtt-broker_address>", {user:"user", password:"pass"});

// You can set callbacks on client events

client.on("<event_type>", callback);

Events fired depends on privilege type.

Admin

The Administrator has the privilege to create and delete users in the database, with the privilege of his choice.

You can see the references on the [[Admin wiki page|Admin]].

Moderator

The moderator has the power to create sensors and to delete those ones. He can specify the type, and the frequency for the simulated sensor.

You can see the references on the [[Moderator wiki page|Moderator]].

Client

The Client has the basic rights : those to connect to the values sent by the simulator.

You can see the references on the [[Client wiki page|Client]].

Examples

Admin

import {Admin} from 'proto-mqtt-client';

let callbacks = {
    onSuccess : (message) => {
        console.log("Created user.");
    },
    onError : (message) => {
        console.log("Failed on user creation..");
    }
}

let client = new Admin("ws://127.0.0.1:8080", {user:"robert", password:"password123"});

client.createUser("billy", "bob", callbacks);
client.deleteUser("billy", callbacks);

Moderator

import {Moderator} from 'proto-mqtt-client';

let callbacks = {
    onSuccess : (message) => {
        console.log("Created sensor.");
    },
    onError : (message) => {
        console.log("Failed on sensor creation..");
    }
}

let client = new Moderator("ws://127.0.0.1:8080", {user:"robert", password:"password123"});

client.createSensor(payload, callbacks);
client.deleteSensor(name, callbacks);

Client

import {Client} from 'proto-mqtt-client';

let client = new Client("ws://127.0.0.1:8080", {user:"robert", password:"password123"});

client.on("message", (topic, payload) => {
    // Le code quand vous recevrez un message
});

client.on("connect", (connack) => {
    // Le code quand vous vous connectez
});

client.on("reconnect", () => {
    // Le code quand une reconnexion a lieu
});

client.on("offline", () => {
    // Le code quand le client est hors ligne.
});

client.on("error", (error) => {
    // Renvoyée quand une erreur a lieu
});

client.subscribe("topic");