GithubHelp home page GithubHelp logo

tempbottle / rust-mq Goto Github PK

View Code? Open in Web Editor NEW

This project forked from inre/rust-mq

0.0 3.0 0.0 836 KB

RustMQ is the MQTT client written on pure Rust.

License: MIT License

Makefile 0.21% Rust 99.79%

rust-mq's Introduction

RustMQ

Build Status

This repository is the bundle of crates devoted to the MQTT protocol.

Crates

  • mqtt3 - MQTT protocol reader/writer Crates.io
  • netopt - TCP/SSL connection Crates.io
  • mqttc - Rust MQTT client Crates.io

Binaries

  • mqttc - Console MQTT client

Client

The client has the following functionality:

  • QoS 0, QoS 1, QoS 2 publish/subscribe
  • Last Will message
  • Auto-Ping
  • Auto-Reconnect
  • SSL supported (include TLS v1.1, TLS v1.2)
  • Modular: mqtt3, netopt
  • Logging

Connect

let netopt = NetworkOptions::new();
let mut opts = ClientOptions::new();
opts.set_reconnect(ReconnectMethod::ReconnectAfter(Duration::from_secs(1)));
let mut client = opts.connect("127.0.0.1:1883", netopt).expect("Can't connect to server");

Publish

client.publish("a/b/c", "hello", PubOpt.at_least_once()).unwrap();
while (client.await().unwrap().is_some()) {};

Subscribe

client.subscribe("a/b/c").unwrap();
loop {
    match client.await().unwrap() {
        Some(message) => {
            println!("{:?}", message);
        },
        None => {}
    }
}

Command line interface

mqtt-cli

MQTT Client installation:

git clone https://github.com/inre/rust-mq.git
cd rust-mq
make && make install

Subscribe to all topics:

mqttc sub

Or try,

mqttc sub -a test.mosquitto.org
mqttc sub -a iot.eclipse.org
mqttc sub -a test.mosca.io
mqttc sub -a broker.hivemq.com

Publish to the topic:

mqttc pub -t a/b/c -m "hello"

Server

Maybe in future

rust-mq's People

Contributors

francozappa avatar hmvp avatar inre avatar jamesmunns avatar llogiq avatar lylescott avatar tshepang avatar

Watchers

 avatar  avatar  avatar

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.