Coder Social home page Coder Social logo

vibe-mqtt's Introduction

Actions Status Dub downloads License Latest version

vibe-mqtt

MQTT broker client library written completely in D.

API documentation

MQTT protocol version supported: 3.1.1

Depends on: vibe.d

Tested on:

Supported MQTT 3.1.1 features:

  • QoS0, QoS1 and QoS2 messages handling
  • Authentication
  • Session state storage (currently in memory only - #20)
  • Sending retain messages
  • Async API (publish blocks if send queue is full)
  • Data agnostic
  • Message ordering
  • KeepAlive mechanism support (PingReq/PingResp) (#11)
  • Auto reconnect to broker (#15)
  • TLS/SSL (#16)
  • On subscribe topics validation (#17)
  • Last Will and Testament (LWT) (#21)
  • Delivery retry (#14)

Pull Requests are welcome, don't be shy ;)

Usage

Example code can be found in the examples directory.

Publisher

Simple publisher which connects to the MQTT broker and periodically sends a message. Implicitly it connects to 127.0.0.1:1883

auto settings = Settings();
settings.clientId = "test publisher";

auto mqtt = new MqttClient(settings);
mqtt.connect();

auto publisher = runTask(() {
        while (mqtt.connected) {
            mqtt.publish("chat", "I'm still here!!!");
            sleep(2.seconds());
        }
    });

Subscriber

Simple subscriber which connects to the MQTT broker, subscribes to the topic and outputs each received message. Implicitly it connects to 127.0.0.1:1883

auto settings = Settings();
settings.clientId = "test subscriber";
settings.onConnAck = (scope MqttClient ctx, in ConnAck packet)
{
    ctx.subscribe(["chat"]);
};
settings.onPublish = (scope MqttClient ctx, in Publish packet)
{
    writeln("chat: ", cast(string)packet.payload);
};

auto mqtt = new MqttClient(settings);
mqtt.connect();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.