fix code in sc-mqtt module
This commit is contained in:
parent
349c2f17cf
commit
fe62f61883
2 changed files with 26 additions and 48 deletions
|
@ -869,27 +869,16 @@ present in the CraftBukkit classpath. To use this module, you should
|
||||||
messages to/from a Net-enabled Arduino or any other device which uses
|
messages to/from a Net-enabled Arduino or any other device which uses
|
||||||
the [MQTT protocol][mqtt]
|
the [MQTT protocol][mqtt]
|
||||||
|
|
||||||
|
|
||||||
var mqtt = require('sc-mqtt');
|
var mqtt = require('sc-mqtt');
|
||||||
|
|
||||||
// create a new client
|
// create a new client
|
||||||
|
|
||||||
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
|
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
|
||||||
|
|
||||||
// connect to the broker
|
// connect to the broker
|
||||||
|
|
||||||
client.connect( { keepAliveInterval: 15 } );
|
client.connect( { keepAliveInterval: 15 } );
|
||||||
|
|
||||||
// publish a message to the broker
|
// publish a message to the broker
|
||||||
|
|
||||||
client.publish( 'minecraft', 'loaded' );
|
client.publish( 'minecraft', 'loaded' );
|
||||||
|
|
||||||
// subscribe to messages on 'arduino' topic
|
// subscribe to messages on 'arduino' topic
|
||||||
|
|
||||||
client.subscribe( 'arduino' );
|
client.subscribe( 'arduino' );
|
||||||
|
|
||||||
// do something when an incoming message arrives...
|
// do something when an incoming message arrives...
|
||||||
|
|
||||||
client.onMessageArrived( function( topic, message ) {
|
client.onMessageArrived( function( topic, message ) {
|
||||||
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
|
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,27 +29,16 @@ present in the CraftBukkit classpath. To use this module, you should
|
||||||
messages to/from a Net-enabled Arduino or any other device which uses
|
messages to/from a Net-enabled Arduino or any other device which uses
|
||||||
the [MQTT protocol][mqtt]
|
the [MQTT protocol][mqtt]
|
||||||
|
|
||||||
|
|
||||||
var mqtt = require('sc-mqtt');
|
var mqtt = require('sc-mqtt');
|
||||||
|
|
||||||
// create a new client
|
// create a new client
|
||||||
|
|
||||||
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
|
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
|
||||||
|
|
||||||
// connect to the broker
|
// connect to the broker
|
||||||
|
|
||||||
client.connect( { keepAliveInterval: 15 } );
|
client.connect( { keepAliveInterval: 15 } );
|
||||||
|
|
||||||
// publish a message to the broker
|
// publish a message to the broker
|
||||||
|
|
||||||
client.publish( 'minecraft', 'loaded' );
|
client.publish( 'minecraft', 'loaded' );
|
||||||
|
|
||||||
// subscribe to messages on 'arduino' topic
|
// subscribe to messages on 'arduino' topic
|
||||||
|
|
||||||
client.subscribe( 'arduino' );
|
client.subscribe( 'arduino' );
|
||||||
|
|
||||||
// do something when an incoming message arrives...
|
// do something when an incoming message arrives...
|
||||||
|
|
||||||
client.onMessageArrived( function( topic, message ) {
|
client.onMessageArrived( function( topic, message ) {
|
||||||
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
|
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue