Skip to content

A high-level WebSocket-Like abstraction of the mqttify implementation of the MQTT v3.1.1 protocol

Notifications You must be signed in to change notification settings

anluin/MqttSocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MqttSocket

A high-level WebSocket-Like abstraction of the mqttify implementation of the MQTT v3.1.1 protocol

This project is an implementation of a high-level abstraction of the MQTT protocol using Deno.

It contains a WebSocket-like class that can handle MQTT connections. The MqttSocket class provides methods for publishing messages, subscribing to topics, and handling authentication. The class also emits events for when the connection is opened, a message is received, a packet is sent or received, an error occurs, the connection is closed, a subscription is made, or an unsubscription is made.

deno module

Usage

import { MqttSocket } from "https://deno.land/x/mqttsocket/mod.ts";


// Create a new MqttSocket instance
const socket = new MqttSocket("mqtt://localhost");

socket.addEventListener("open", async () => {
    // Subscribe to a topic
    await socket.subscribe("test");

    // Publish a message
    await socket.publish({
        topic: "test",
        payload: "Hello, MQTT!",
    });
});

// Receive messages
socket.addEventListener("message", (event) => {
    console.log("Received message:", event.message.payload.text);
});

You can import the MqttSocket class from the mod.ts file. The class provides methods for publishing messages, subscribing to topics, and handling authentication. It also emits events for various actions on the MQTT connection.

About

A high-level WebSocket-Like abstraction of the mqttify implementation of the MQTT v3.1.1 protocol

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published