Skip to content

Commit fe62f61

Browse files
committed
fix code in sc-mqtt module
1 parent 349c2f1 commit fe62f61

2 files changed

Lines changed: 26 additions & 48 deletions

File tree

docs/API-Reference.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -869,30 +869,19 @@ present in the CraftBukkit classpath. To use this module, you should
869869
messages to/from a Net-enabled Arduino or any other device which uses
870870
the [MQTT protocol][mqtt]
871871

872-
873-
var mqtt = require('sc-mqtt');
874-
875-
// create a new client
876-
877-
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
878-
879-
// connect to the broker
880-
881-
client.connect( { keepAliveInterval: 15 } );
882-
883-
// publish a message to the broker
884-
885-
client.publish( 'minecraft', 'loaded' );
886-
887-
// subscribe to messages on 'arduino' topic
888-
889-
client.subscribe( 'arduino' );
890-
891-
// do something when an incoming message arrives...
892-
893-
client.onMessageArrived( function( topic, message ) {
894-
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
895-
});
872+
var mqtt = require('sc-mqtt');
873+
// create a new client
874+
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
875+
// connect to the broker
876+
client.connect( { keepAliveInterval: 15 } );
877+
// publish a message to the broker
878+
client.publish( 'minecraft', 'loaded' );
879+
// subscribe to messages on 'arduino' topic
880+
client.subscribe( 'arduino' );
881+
// do something when an incoming message arrives...
882+
client.onMessageArrived( function( topic, message ) {
883+
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
884+
});
896885

897886
The `sc-mqtt` module provides a very simple minimal wrapper around the
898887
[Eclipse Paho MQTT Version 3 Client][pahodocs] java-based MQTT

src/main/js/modules/sc-mqtt.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,19 @@ present in the CraftBukkit classpath. To use this module, you should
2929
messages to/from a Net-enabled Arduino or any other device which uses
3030
the [MQTT protocol][mqtt]
3131
32-
33-
var mqtt = require('sc-mqtt');
34-
35-
// create a new client
36-
37-
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
38-
39-
// connect to the broker
40-
41-
client.connect( { keepAliveInterval: 15 } );
42-
43-
// publish a message to the broker
44-
45-
client.publish( 'minecraft', 'loaded' );
46-
47-
// subscribe to messages on 'arduino' topic
48-
49-
client.subscribe( 'arduino' );
50-
51-
// do something when an incoming message arrives...
52-
53-
client.onMessageArrived( function( topic, message ) {
54-
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
55-
});
32+
var mqtt = require('sc-mqtt');
33+
// create a new client
34+
var client = mqtt.client( 'tcp://localhost:1883', 'uniqueClientId' );
35+
// connect to the broker
36+
client.connect( { keepAliveInterval: 15 } );
37+
// publish a message to the broker
38+
client.publish( 'minecraft', 'loaded' );
39+
// subscribe to messages on 'arduino' topic
40+
client.subscribe( 'arduino' );
41+
// do something when an incoming message arrives...
42+
client.onMessageArrived( function( topic, message ) {
43+
console.log( 'Message arrived: topic=' + topic + ', message=' + message );
44+
});
5645
5746
The `sc-mqtt` module provides a very simple minimal wrapper around the
5847
[Eclipse Paho MQTT Version 3 Client][pahodocs] java-based MQTT

0 commit comments

Comments
 (0)