Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.

Latest commit

 

History

History
51 lines (36 loc) · 1.25 KB

README.md

File metadata and controls

51 lines (36 loc) · 1.25 KB

Haho

GitHub stars npm version npm license npm

Haho mqtt plugin for hapi.js.

Paho Mqtt moves into Hapi then they call it Haho. 😜

Usage

const Hapi = require('hapi');


const server = new Hapi.Server();

server.connection({
    port: '9090'
});

server.register({
    register: require('Haho'),
    options: {
        url: 'mqtt://localhost:1883'
    }
}, (err) => {

    if (err) {
        console.log('Failed loading plugin');
    }
    
    const haho = server.plugins.haho;
    haho.subscribe('test/hello', (topic, message) => {

        console.log('message', message);
    });
    
    /* start the server after plugin registration */
    server.start((err) => {

        if (err) {
            console.log('error when starting server', err);
        }
        console.log('service started');
    });
});