as

adhesion-server

Use MQTT directly in your web pages using WebSockets

Showing:

Popularity

Downloads/wk

1

Maintenance

No Maintenance Data Available

Package

Dependencies

3

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Adhesion Server

Note: The previous version of Adhesion is still available on this addess but will not longer be actively maintained. Use this version instead.

Adhesion is a simple module to provide a bridge between your MQTT broker and a WebSockets. This way you can use MQTT in your browser apps without having to expose your broker to the world. A powerful but simple feature is the ability to allow or deny a subscribe or publish request based on your own logic.

For a version you can use right away, try adhesion-proxy.

Install

npm install adhesion-server --save

Usage example


var Adhesion = require('./Server');

/*
 Options to feed the server
*/
var options = {
    'mqtt': {
        'url': 'mqtt://localhost'
    },
    'ws': {
        'port': 7897
    }
};

var server = Adhesion.createServer(options);
// Optionally: var server = Adhesion.createServer(options, connectionListener);

/*
 A new WS client connected
*/
server.on('connection', function(client) {

    /*
     The client requested a subscription to a topic
    */
    client.on('subscribe', function(topic, allow) {

        // You can do any checks you want here.
        // Just call allow() with true or false when you're done
        return allow(true);

        // In >0.0.2 you can also do this:
        return allow(false, 'You don\'t have sufficient access!');

    });

    /*
     The client requested a publication on a topic
    */
    client.on('publish', function(topic, message, flags, allow) {

        // You can do any checks you want here.
        // Just call allow() with true or false when you're done
        return allow(true);

    });

});

That's all there is to it!

Version history

  • 0.0.2 - 21 July 2015
    • Added optional reason to allow callback
  • 0.0.1 - 20 July 2015
    • First commit

License

Copyright 2015 Michiel van der Velde.

This software is licensed under the MIT License.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial