Skip to content

erichardson-lee/MQTT.ts

 
 

Repository files navigation

MQTT.ts

This repo is a fork of JDiamond/MQTT.ts as it is no longer maintained.

This is an implementation of the MQTT 3.1.1 protocol written in TypeScript.

Quick Start

import { Client } from "https://deno.land/x/mqtt/deno/mod.ts";

const client = new Client({ url: "mqtt://test.mosquitto.org" });

await client.connect();

await client.subscribe("incoming/#");

client.on("message", (topic, payload) => {
  console.log(topic, payload);
});

await client.publish("my/topic", "my payload");

await client.disconnect();

Examples

Look in examples/ to see examples of using the client.

There are some CLI tools in tools that are similar to mosquitto_pub and mosquitto_sub.

To subscribe:

deno run --allow-net tools/sub.ts -u mqtt://test.mosquitto.org -t "MQTT.ts/test/topic" -v

To publish:

deno run --allow-net tools/pub.ts -u mqtt://test.mosquitto.org -t "MQTT.ts/test/topic" -m "hello"

Development

See CONTRIBUTING.md

About

MQTT in TypeScript for Deno, Node.js, and browsers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%