Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var test = require('tape').test
, mqtt = require('mqtt-connection')
, parseStream = mqtt.parseStream
, generateStream = mqtt.generateStream
, through = require('through2')
, reduplexer = require('reduplexer')
, aedes = require('../')
, clients = 0
function setup(broker) {
var inStream = generateStream()
, outStream = parseStream()
, conn = reduplexer(outStream, inStream)
broker = broker || aedes()
broker.handle(conn)
conn.destroy = function() {
inStream.destroy()
'use strict'
var mqtt = require('mqtt-connection')
var through = require('through2')
var aedes = require('../')
var duplexify = require('duplexify')
var parseStream = mqtt.parseStream
var generateStream = mqtt.generateStream
var clients = 0
function setup (broker, autoClose) {
var inStream = generateStream()
var outStream = parseStream()
var conn = duplexify(outStream, inStream)
broker = broker || aedes()
broker.handle(conn)
if (autoClose === undefined || autoClose) {
setTimeout(function () {
broker.close()
}, autoClose || 200)
}
'use strict'
var mqtt = require('mqtt-connection')
var through = require('through2')
var aedes = require('../')
var duplexify = require('duplexify')
var parseStream = mqtt.parseStream
var generateStream = mqtt.generateStream
var clients = 0
function setup (broker, autoClose) {
var inStream = generateStream()
var outStream = parseStream()
var conn = duplexify(outStream, inStream)
broker = broker || aedes()
broker.handle(conn)
if (autoClose === undefined || autoClose) {
setTimeout(function () {
broker.close()
}, autoClose || 200)
var test = require('tape').test
, mqtt = require('mqtt-connection')
, parseStream = mqtt.parseStream
, generateStream = mqtt.generateStream
, through = require('through2')
, reduplexer = require('reduplexer')
, aedes = require('../')
, clients = 0
function setup(broker) {
var inStream = generateStream()
, outStream = parseStream()
, conn = reduplexer(outStream, inStream)
broker = broker || aedes()
broker.handle(conn)
conn.destroy = function() {
const createServerHandler = (pubsubManager, callback, appId, qos) => ws => {
const stream = getWebSocketStream(ws)
const client = new MqttConnection(stream)
let messageId = 1
const publisher = (topicName, topicId, event) =>
new Promise((resolve, reject) => {
client.publish(
{
topic: getMqttTopic(appId, { topicName, topicId }),
payload: JSON.stringify(event),
messageId: messageId++,
qos
},
error => (error ? reject(error) : resolve())
)
})
client.on('connect', () => {
const createServerMqttHandler = (pubsubManager, appId, qos) => ws => {
const stream = getWebSocketStream(ws)
const client = new MqttConnection(stream)
let messageId = 1
const publisher = (topicName, topicId, event) =>
new Promise((resolve, reject) => {
client.publish(
{
topic: getMqttTopic(appId, { topicName, topicId }),
payload: JSON.stringify(event),
messageId: messageId++,
qos
},
error => (error ? reject(error) : resolve())
)
})
client.on('connect', () => {
const createServerMqttHandler = (pubsubManager, appId, qos) => ws => {
const stream = getWebSocketStream(ws)
const client = new MqttConnection(stream)
let messageId = 1
const publisher = (topicName, topicId, event) =>
new Promise((resolve, reject) => {
client.publish(
{
topic: getMqttTopic(appId, { topicName, topicId }),
payload: JSON.stringify(event),
messageId: messageId++,
qos
},
error => (error ? reject(error) : resolve())
)
})
client.on('connect', () => {