From fe62f61883a8fd861d8b7d955c4e17c3a3a67168 Mon Sep 17 00:00:00 2001 From: walterhiggins Date: Tue, 4 Feb 2014 21:04:12 +0000 Subject: [PATCH] fix code in sc-mqtt module --- docs/API-Reference.md | 37 ++++++++++++---------------------- src/main/js/modules/sc-mqtt.js | 37 ++++++++++++---------------------- 2 files changed, 26 insertions(+), 48 deletions(-) diff --git a/docs/API-Reference.md b/docs/API-Reference.md index 74b6398..87596b1 100644 --- a/docs/API-Reference.md +++ b/docs/API-Reference.md @@ -869,30 +869,19 @@ present in the CraftBukkit classpath. To use this module, you should messages to/from a Net-enabled Arduino or any other device which uses the [MQTT protocol][mqtt] - - var mqtt = require('sc-mqtt'); - - // create a new client - - var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' ); - - // connect to the broker - - client.connect( { keepAliveInterval: 15 } ); - - // publish a message to the broker - - client.publish( 'minecraft', 'loaded' ); - - // subscribe to messages on 'arduino' topic - - client.subscribe( 'arduino' ); - - // do something when an incoming message arrives... - - client.onMessageArrived( function( topic, message ) { - console.log( 'Message arrived: topic=' + topic + ', message=' + message ); - }); + var mqtt = require('sc-mqtt'); + // create a new client + var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' ); + // connect to the broker + client.connect( { keepAliveInterval: 15 } ); + // publish a message to the broker + client.publish( 'minecraft', 'loaded' ); + // subscribe to messages on 'arduino' topic + client.subscribe( 'arduino' ); + // do something when an incoming message arrives... + client.onMessageArrived( function( topic, message ) { + console.log( 'Message arrived: topic=' + topic + ', message=' + message ); + }); The `sc-mqtt` module provides a very simple minimal wrapper around the [Eclipse Paho MQTT Version 3 Client][pahodocs] java-based MQTT diff --git a/src/main/js/modules/sc-mqtt.js b/src/main/js/modules/sc-mqtt.js index 2846b49..99069ab 100644 --- a/src/main/js/modules/sc-mqtt.js +++ b/src/main/js/modules/sc-mqtt.js @@ -29,30 +29,19 @@ present in the CraftBukkit classpath. To use this module, you should messages to/from a Net-enabled Arduino or any other device which uses the [MQTT protocol][mqtt] - - var mqtt = require('sc-mqtt'); - - // create a new client - - var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' ); - - // connect to the broker - - client.connect( { keepAliveInterval: 15 } ); - - // publish a message to the broker - - client.publish( 'minecraft', 'loaded' ); - - // subscribe to messages on 'arduino' topic - - client.subscribe( 'arduino' ); - - // do something when an incoming message arrives... - - client.onMessageArrived( function( topic, message ) { - console.log( 'Message arrived: topic=' + topic + ', message=' + message ); - }); + var mqtt = require('sc-mqtt'); + // create a new client + var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' ); + // connect to the broker + client.connect( { keepAliveInterval: 15 } ); + // publish a message to the broker + client.publish( 'minecraft', 'loaded' ); + // subscribe to messages on 'arduino' topic + client.subscribe( 'arduino' ); + // do something when an incoming message arrives... + client.onMessageArrived( function( topic, message ) { + console.log( 'Message arrived: topic=' + topic + ', message=' + message ); + }); The `sc-mqtt` module provides a very simple minimal wrapper around the [Eclipse Paho MQTT Version 3 Client][pahodocs] java-based MQTT