forked from mqttjs/MQTT.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
2,336 additions
and
2,831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
#! /usr/bin/env node | ||
|
||
var mqtt = require('../'); | ||
var client = mqtt.connect({ port: 1883, host: "localhost", clean: true, keepalive: 0 }); | ||
var mqtt = require('../') | ||
var client = mqtt.connect({ port: 1883, host: 'localhost', clean: true, keepalive: 0 }) | ||
|
||
var sent = 0; | ||
var interval = 5000; | ||
var sent = 0 | ||
var interval = 5000 | ||
|
||
function count() { | ||
console.log("sent/s", sent / interval * 1000); | ||
sent = 0; | ||
function count () { | ||
console.log('sent/s', sent / interval * 1000) | ||
sent = 0 | ||
} | ||
|
||
setInterval(count, interval) | ||
|
||
function publish() { | ||
sent++; | ||
client.publish("test", "payload", publish); | ||
function publish () { | ||
sent++ | ||
client.publish('test', 'payload', publish) | ||
} | ||
|
||
client.on("connect", publish); | ||
client.on('connect', publish) | ||
|
||
client.on("error", function() { | ||
console.log("reconnect!"); | ||
client.stream.end(); | ||
}); | ||
client.on('error', function () { | ||
console.log('reconnect!') | ||
client.stream.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
#! /usr/bin/env node | ||
|
||
var mqtt = require('../'); | ||
var mqtt = require('../') | ||
|
||
var client = mqtt.connect({ port: 1883, host: "localhost", clean: true, encoding: 'binary', keepalive: 0 }); | ||
var counter = 0; | ||
var interval = 5000; | ||
var client = mqtt.connect({ port: 1883, host: 'localhost', clean: true, encoding: 'binary', keepalive: 0 }) | ||
var counter = 0 | ||
var interval = 5000 | ||
|
||
function count() { | ||
console.log("received/s", counter / interval * 1000); | ||
counter = 0; | ||
function count () { | ||
console.log('received/s', counter / interval * 1000) | ||
counter = 0 | ||
} | ||
|
||
setInterval(count, interval); | ||
setInterval(count, interval) | ||
|
||
client.on('connect', function() { | ||
count(); | ||
this.subscribe('test'); | ||
this.on("message", function() { | ||
counter++; | ||
}); | ||
}); | ||
client.on('connect', function () { | ||
count() | ||
this.subscribe('test') | ||
this.on('message', function () { | ||
counter++ | ||
}) | ||
}) |
Oops, something went wrong.