node-red-contrib-aedes 0.5.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ jobs:
9
9
 
10
10
  strategy:
11
11
  matrix:
12
- node-version: [10.x, 12.x, 14.x]
12
+ node-version: [14.x, 16.x, 18.x]
13
13
 
14
14
  steps:
15
15
  - uses: actions/checkout@v2
@@ -18,7 +18,7 @@ jobs:
18
18
  with:
19
19
  node-version: ${{ matrix.node-version }}
20
20
  - run: npm install
21
- - run: npm install -g node-red@1.2.9
21
+ - run: npm install -g node-red
22
22
  - run: npm link node-red
23
23
  - run: npm install -g mocha
24
24
  - run: npm install -g semistandard
package/.travis.yml CHANGED
@@ -14,8 +14,9 @@ services:
14
14
  - mongodb
15
15
  node_js:
16
16
  - "12"
17
+ - "14"
17
18
  before_script:
18
- - npm install -g node-red@1.2.9
19
+ - npm install -g node-red
19
20
  - npm link node-red
20
21
  - npm install -g mocha
21
22
  - npm install -g semistandard
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # node-red-contrib-aedes Changelog
2
2
 
3
+ ## May 22, 2022, Version 0.8
4
+ ### Notable changes
5
+ - Update aedes to version 0.47
6
+
7
+ ## Feb 18, 2022, Version 0.7
8
+ ### Notable changes
9
+ - Fix Close Time Out Issue
10
+ ## Oct 17, 2021, Version 0.6
11
+ ### Notable changes
12
+ - Add output node for publish events
13
+
3
14
  ## Apr 23, 2021, Version 0.5.2
4
15
  ### Notable changes
5
16
  - Update aedes to version 0.46
package/aedes.html CHANGED
@@ -133,7 +133,7 @@
133
133
  },
134
134
  color: '#d8bfd8',
135
135
  inputs: 0,
136
- outputs: 1,
136
+ outputs: 2,
137
137
  icon: 'aedes.png',
138
138
  label: function () {
139
139
  return this.name || 'Aedes MQTT broker';
@@ -141,6 +141,7 @@
141
141
  labelStyle: function () {
142
142
  return this.name ? 'node_label_italic' : '';
143
143
  },
144
+ outputLabels: ["events","publish"],
144
145
  oneditprepare: function () {
145
146
  var tabs = RED.tabs.create({
146
147
  id: 'node-config-aedes-broker-tabs',
package/aedes.js CHANGED
@@ -170,7 +170,9 @@ module.exports = function (RED) {
170
170
  if (this.credentials && this.username && this.password) {
171
171
  const authenticate = function (client, username, password, callback) {
172
172
  const authorized = (username === node.username && password.toString() === node.password);
173
- if (authorized) { client.user = username; }
173
+ if (authorized) {
174
+ client.user = username;
175
+ }
174
176
  callback(null, authorized);
175
177
  };
176
178
 
@@ -184,7 +186,7 @@ module.exports = function (RED) {
184
186
  client: client
185
187
  }
186
188
  };
187
- node.send(msg);
189
+ node.send([msg, null]);
188
190
  });
189
191
 
190
192
  broker.on('clientReady', function (client) {
@@ -194,8 +196,12 @@ module.exports = function (RED) {
194
196
  client: client
195
197
  }
196
198
  };
197
- node.status({ fill: 'green', shape: 'dot', text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients }) });
198
- node.send(msg);
199
+ node.status({
200
+ fill: 'green',
201
+ shape: 'dot',
202
+ text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients })
203
+ });
204
+ node.send([msg, null]);
199
205
  });
200
206
 
201
207
  broker.on('clientDisconnect', function (client) {
@@ -205,8 +211,12 @@ module.exports = function (RED) {
205
211
  client: client
206
212
  }
207
213
  };
208
- node.send(msg);
209
- node.status({ fill: 'green', shape: 'dot', text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients }) });
214
+ node.send([msg, null]);
215
+ node.status({
216
+ fill: 'green',
217
+ shape: 'dot',
218
+ text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients })
219
+ });
210
220
  });
211
221
 
212
222
  broker.on('clientError', function (client, err) {
@@ -217,8 +227,12 @@ module.exports = function (RED) {
217
227
  err: err
218
228
  }
219
229
  };
220
- node.send(msg);
221
- node.status({ fill: 'green', shape: 'dot', text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients }) });
230
+ node.send([msg, null]);
231
+ node.status({
232
+ fill: 'green',
233
+ shape: 'dot',
234
+ text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients })
235
+ });
222
236
  });
223
237
 
224
238
  broker.on('connectionError', function (client, err) {
@@ -229,8 +243,12 @@ module.exports = function (RED) {
229
243
  err: err
230
244
  }
231
245
  };
232
- node.send(msg);
233
- node.status({ fill: 'green', shape: 'dot', text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients }) });
246
+ node.send([msg, null]);
247
+ node.status({
248
+ fill: 'green',
249
+ shape: 'dot',
250
+ text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients })
251
+ });
234
252
  });
235
253
 
236
254
  broker.on('keepaliveTimeout', function (client) {
@@ -240,8 +258,12 @@ module.exports = function (RED) {
240
258
  client: client
241
259
  }
242
260
  };
243
- node.send(msg);
244
- node.status({ fill: 'green', shape: 'dot', text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients }) });
261
+ node.send([msg, null]);
262
+ node.status({
263
+ fill: 'green',
264
+ shape: 'dot',
265
+ text: RED._('aedes-mqtt-broker.status.connected', { count: broker.connectedClients })
266
+ });
245
267
  });
246
268
 
247
269
  broker.on('subscribe', function (subscription, client) {
@@ -253,7 +275,7 @@ module.exports = function (RED) {
253
275
  client: client
254
276
  }
255
277
  };
256
- node.send(msg);
278
+ node.send([msg, null]);
257
279
  });
258
280
 
259
281
  broker.on('unsubscribe', function (subscription, client) {
@@ -265,48 +287,51 @@ module.exports = function (RED) {
265
287
  client: client
266
288
  }
267
289
  };
268
- node.send(msg);
290
+ node.send([msg, null]);
269
291
  });
270
292
 
271
- /*
272
- broker.on('publish', function (packet, client) {
273
- var msg = {
274
- topic: 'publish',
275
- payload: {
276
- packet: packet,
277
- client: client
278
- }
279
- };
280
- node.send(msg);
281
- });
282
- */
293
+ if (this.wires && this.wires[1] && this.wires[1].length > 0) {
294
+ node.log('Publish output wired. Enable broker publish event messages.');
295
+ broker.on('publish', function (packet, client) {
296
+ const msg = {
297
+ topic: 'publish',
298
+ payload: {
299
+ packet: packet,
300
+ client: client
301
+ }
302
+ };
303
+ node.send([null, msg]);
304
+ });
305
+ }
283
306
 
284
307
  broker.on('closed', function () {
285
308
  node.debug('Closed event');
286
309
  });
287
310
 
288
311
  this.on('close', function (done) {
289
- broker.close(function () {
290
- node.log('Unbinding aedes mqtt server from port: ' + config.mqtt_port);
291
- server.close(function () {
292
- node.debug('after server.close(): ');
293
- if (node.mqtt_ws_path !== '') {
294
- node.log('Unbinding aedes mqtt server from ws path: ' + node.fullPath);
295
- delete listenerNodes[node.fullPath];
296
- node.server.close();
297
- }
298
- if (wss) {
299
- node.log('Unbinding aedes mqtt server from ws port: ' + config.mqtt_ws_port);
300
- wss.close(function () {
301
- node.debug('after wss.close(): ');
302
- httpServer.close(function () {
303
- node.debug('after httpServer.close(): ');
304
- done();
312
+ process.nextTick(function onCloseDelayed () {
313
+ broker.close(function () {
314
+ node.log('Unbinding aedes mqtt server from port: ' + config.mqtt_port);
315
+ server.close(function () {
316
+ node.debug('after server.close(): ');
317
+ if (node.mqtt_ws_path !== '') {
318
+ node.log('Unbinding aedes mqtt server from ws path: ' + node.fullPath);
319
+ delete listenerNodes[node.fullPath];
320
+ node.server.close();
321
+ }
322
+ if (wss) {
323
+ node.log('Unbinding aedes mqtt server from ws port: ' + config.mqtt_ws_port);
324
+ wss.close(function () {
325
+ node.debug('after wss.close(): ');
326
+ httpServer.close(function () {
327
+ node.debug('after httpServer.close(): ');
328
+ done();
329
+ });
305
330
  });
306
- });
307
- } else {
308
- done();
309
- }
331
+ } else {
332
+ done();
333
+ }
334
+ });
310
335
  });
311
336
  });
312
337
  });
package/flows.png CHANGED
Binary file
@@ -2,10 +2,13 @@
2
2
  <p>MQTT broker based on Barebone MQTT broker Aedes. You can use MQTT-in and MQTT-out nodes without an external broker like Mosquitto.</p>
3
3
  <h3>Outputs</h3>
4
4
  <dl class="message-properties">
5
- <dt>payload <span class="property-type">object</span></dt>
6
- <dd>the content of the events from the broker.</dd>
7
5
  <dt>topic <span class="property-type">string</span></dt>
8
6
  <dd>the topic of the event.</dd>
7
+ <dt>payload 1<span class="property-type">object</span></dt>
8
+ <dd>the content of all events from the broker except publish.</dd>
9
+ <dt>payload 2<span class="property-type">object</span></dt>
10
+ <dd>the content of the publish events from the broker.</dd>
11
+
9
12
  </dl>
10
13
  <h3>Details</h3>
11
14
  <h3>References</h3>
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "node-red-contrib-aedes",
3
- "version": "0.5.2",
3
+ "version": "0.8.0",
4
4
  "description": "Node Red MQTT broker node based on aedes.js",
5
5
  "dependencies": {
6
- "aedes": "^0.46.0",
7
- "aedes-persistence-mongodb": "^8.2.0",
6
+ "aedes": "^0.47.0",
7
+ "aedes-persistence-mongodb": "^9.0.0",
8
8
  "websocket-stream": "^5.5.2"
9
9
  },
10
10
  "devDependencies": {
11
- "mqtt": "^4.2.6",
11
+ "mqtt": "^4.3.7",
12
12
  "node-red-node-test-helper": "^0.2.7"
13
13
  },
14
14
  "scripts": {
15
- "test": "semistandard --verbose | snazzy && mocha test/**/*_spec.js"
15
+ "test": "semistandard --verbose | snazzy && mocha test/**/*.js --exit"
16
16
  },
17
17
  "node-red": {
18
18
  "nodes": {
@@ -22,7 +22,10 @@ describe('Aedes Broker Last Will tests', function () {
22
22
  id: 'n1',
23
23
  type: 'aedes broker',
24
24
  mqtt_port: '1883',
25
- name: 'Aedes 1883'
25
+ name: 'Aedes 1883',
26
+ wires: [
27
+ [], []
28
+ ]
26
29
  }];
27
30
  helper.load(aedesNode, flow, function () {
28
31
  const n1 = helper.getNode('n1');
@@ -40,7 +43,7 @@ describe('Aedes Broker Last Will tests', function () {
40
43
  mqtt_port: '1883',
41
44
  name: 'Aedes 1883',
42
45
  wires: [
43
- ['n2']
46
+ ['n2'], []
44
47
  ]
45
48
  },
46
49
  {
@@ -48,14 +51,17 @@ describe('Aedes Broker Last Will tests', function () {
48
51
  type: 'helper'
49
52
  }
50
53
  ];
51
- const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1', will: { topic: 'testLastWill', payload: 'last will' } });
52
- client1.on('error', function (err) {
53
- console.error('Error: ', err.toString());
54
- });
55
- client1.on('connect', function () {
56
- // console.log('External client1 connected');
57
- });
58
54
  helper.load([aedesNode], flow, function () {
55
+ const client1 = mqtt.connect('mqtt://localhost:1883', {
56
+ clientId: 'client1',
57
+ will: { topic: 'testLastWill', payload: 'last will' }
58
+ });
59
+ client1.on('error', function (err) {
60
+ console.error('Error: ', err.toString());
61
+ });
62
+ client1.on('connect', function () {
63
+ // console.log('External client1 connected');
64
+ });
59
65
  const n2 = helper.getNode('n2');
60
66
  n2.on('input', function (msg) {
61
67
  // console.log('Broker received message topic: ' + msg.topic + ', clientid: ' + msg.payload.client.id);
@@ -23,7 +23,10 @@ describe('Aedes Broker QOS tests', function () {
23
23
  id: 'n1',
24
24
  type: 'aedes broker',
25
25
  mqtt_port: '1883',
26
- name: 'Aedes 1883'
26
+ name: 'Aedes 1883',
27
+ wires: [
28
+ [], []
29
+ ]
27
30
  }];
28
31
  helper.load(aedesNode, flow, function () {
29
32
  const n1 = helper.getNode('n1');
@@ -40,7 +43,7 @@ describe('Aedes Broker QOS tests', function () {
40
43
  mqtt_port: '1883',
41
44
  name: 'Aedes 1883',
42
45
  wires: [
43
- ['n2']
46
+ ['n2'], []
44
47
  ]
45
48
  },
46
49
  {
@@ -48,28 +51,28 @@ describe('Aedes Broker QOS tests', function () {
48
51
  type: 'helper'
49
52
  }
50
53
  ];
51
- const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
52
- client1.on('error', function (err) {
53
- console.error('Error: ', err.toString());
54
- });
55
- client1.on('connect', function () {
56
- // console.log('External client1 connected');
57
- });
58
- const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2', clean: false });
59
- client2.on('error', function (err) {
60
- console.error('Error: ', err.toString());
61
- });
62
- client2.on('connect', function () {
63
- // console.log('External client2 connected');
64
- client2.subscribe('test1883', { qos: 1 }, function (err, granted) {
65
- // console.log('Subscription successful ' + JSON.stringify(granted));
66
- if (err) {
67
- console.error('Error subscribing');
68
- done();
69
- }
70
- });
71
- });
72
54
  helper.load([aedesNode, mqttNode], flow, function () {
55
+ const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
56
+ client1.on('error', function (err) {
57
+ console.error('Error: ', err.toString());
58
+ });
59
+ client1.on('connect', function () {
60
+ // console.log('External client1 connected');
61
+ });
62
+ const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2', clean: false });
63
+ client2.on('error', function (err) {
64
+ console.error('Error: ', err.toString());
65
+ });
66
+ client2.on('connect', function () {
67
+ // console.log('External client2 connected');
68
+ client2.subscribe('test1883', { qos: 1 }, function (err, granted) {
69
+ // console.log('Subscription successful ' + JSON.stringify(granted));
70
+ if (err) {
71
+ console.error('Error subscribing');
72
+ done();
73
+ }
74
+ });
75
+ });
73
76
  const n2 = helper.getNode('n2');
74
77
  n2.on('input', function (msg) {
75
78
  // console.log('Broker received message topic: ' + msg.topic + ', clientid: ' + msg.payload.client.id);
@@ -108,7 +111,7 @@ describe('Aedes Broker QOS tests', function () {
108
111
  mqtt_port: '1883',
109
112
  name: 'Aedes 1883',
110
113
  wires: [
111
- ['n2']
114
+ ['n2'], []
112
115
  ]
113
116
  },
114
117
  {
@@ -116,29 +119,28 @@ describe('Aedes Broker QOS tests', function () {
116
119
  type: 'helper'
117
120
  }
118
121
  ];
119
- const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
120
- client1.on('error', function (err) {
121
- console.error('Error: ', err.toString());
122
- });
123
- client1.on('connect', function () {
124
- // console.log('External client1 connected');
125
- });
126
- const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2', clean: false });
127
- client2.on('error', function (err) {
128
- console.error('Error: ', err.toString());
129
- });
130
- client2.on('connect', function () {
131
- // console.log('External client2 connected');
132
- client2.subscribe('test1883', { qos: 2 }, function (err, granted) {
133
- // console.log('Subscription successful ' + JSON.stringify(granted));
134
- if (err) {
135
- console.error('Error subscribing');
136
- done();
137
- }
138
- });
139
- });
140
122
  helper.load([aedesNode, mqttNode], flow, function () {
141
- const n2 = helper.getNode('n2');
123
+ const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
124
+ client1.on('error', function (err) {
125
+ console.error('Error: ', err.toString());
126
+ });
127
+ client1.on('connect', function () {
128
+ // console.log('External client1 connected');
129
+ });
130
+ const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2', clean: false });
131
+ client2.on('error', function (err) {
132
+ console.error('Error: ', err.toString());
133
+ });
134
+ client2.on('connect', function () {
135
+ // console.log('External client2 connected');
136
+ client2.subscribe('test1883', { qos: 2 }, function (err, granted) {
137
+ // console.log('Subscription successful ' + JSON.stringify(granted));
138
+ if (err) {
139
+ console.error('Error subscribing');
140
+ done();
141
+ }
142
+ });
143
+ }); const n2 = helper.getNode('n2');
142
144
  n2.on('input', function (msg) {
143
145
  // console.log('Broker received message topic: ' + msg.topic + ', clientid: ' + msg.payload.client.id);
144
146
  if (msg.topic === 'subscribe') {
@@ -23,7 +23,10 @@ describe('Aedes Broker retain tests', function () {
23
23
  id: 'n1',
24
24
  type: 'aedes broker',
25
25
  mqtt_port: '1883',
26
- name: 'Aedes 1883'
26
+ name: 'Aedes 1883',
27
+ wires: [
28
+ [], []
29
+ ]
27
30
  }];
28
31
  helper.load(aedesNode, flow, function () {
29
32
  const n1 = helper.getNode('n1');
@@ -40,7 +43,7 @@ describe('Aedes Broker retain tests', function () {
40
43
  mqtt_port: '1883',
41
44
  name: 'Aedes 1883',
42
45
  wires: [
43
- ['n2']
46
+ ['n2'], []
44
47
  ]
45
48
  },
46
49
  {
@@ -48,34 +51,33 @@ describe('Aedes Broker retain tests', function () {
48
51
  type: 'helper'
49
52
  }
50
53
  ];
51
- const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
52
- const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2' });
53
- client1.on('error', function (err) {
54
- console.error('Error: ', err.toString());
55
- });
56
- client1.on('connect', function () {
57
- // console.log('External client1 connected');
58
- client1.publish('test1883', 'test', { retain: true }, function () {
59
- // console.log('Published test');
60
- client2.on('error', function (err) {
61
- console.error('Error: ', err.toString());
62
- });
63
- client2.on('connect', function () {
64
- // console.log('External client2 connected');
65
- setTimeout(function () {
66
- client2.subscribe('test1883', function (err, granted) {
67
- // console.log('Subscription successful ' + JSON.stringify(granted));
68
- if (err) {
69
- console.error('Error subscribing');
70
- done();
71
- }
72
- });
73
- }, 1000);
74
- });
75
- });
76
- });
77
54
  helper.load([aedesNode, mqttNode], flow, function () {
78
- const n2 = helper.getNode('n2');
55
+ const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
56
+ const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2' });
57
+ client1.on('error', function (err) {
58
+ console.error('Error: ', err.toString());
59
+ });
60
+ client1.on('connect', function () {
61
+ // console.log('External client1 connected');
62
+ client1.publish('test1883', 'test', { retain: true }, function () {
63
+ // console.log('Published test');
64
+ client2.on('error', function (err) {
65
+ console.error('Error: ', err.toString());
66
+ });
67
+ client2.on('connect', function () {
68
+ // console.log('External client2 connected');
69
+ setTimeout(function () {
70
+ client2.subscribe('test1883', function (err, granted) {
71
+ // console.log('Subscription successful ' + JSON.stringify(granted));
72
+ if (err) {
73
+ console.error('Error subscribing');
74
+ done();
75
+ }
76
+ });
77
+ }, 1000);
78
+ });
79
+ });
80
+ }); const n2 = helper.getNode('n2');
79
81
  n2.on('input', function (msg) {
80
82
  // console.log('Broker received message topic: ' + msg.topic + ', clientid: ' + msg.payload.client.id);
81
83
  if (msg.topic === 'subscribe') {
@@ -105,7 +107,7 @@ describe('Aedes Broker retain tests', function () {
105
107
  mqtt_port: '1883',
106
108
  name: 'Aedes 1883',
107
109
  wires: [
108
- ['n2']
110
+ ['n2'], []
109
111
  ]
110
112
  },
111
113
  {
@@ -113,37 +115,36 @@ describe('Aedes Broker retain tests', function () {
113
115
  type: 'helper'
114
116
  }
115
117
  ];
116
- const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
117
- const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2' });
118
- client1.on('error', function (err) {
119
- console.error('Error: ', err.toString());
120
- });
121
- client1.on('connect', function () {
122
- // console.log('External client1 connected');
123
- client1.publish('test1883', 'test1', { retain: true }, function () {
124
- // console.log('Published test1');
125
- client1.publish('test1883', 'test2', { retain: true }, function () {
126
- // console.log('Published test2');
127
- client2.on('error', function (err) {
128
- console.error('Error: ', err.toString());
129
- });
130
- client2.on('connect', function () {
131
- // console.log('External client2 connected');
132
- setTimeout(function () {
133
- client2.subscribe('test1883', function (err, granted) {
134
- // console.log('Subscription successful ' + JSON.stringify(granted));
135
- if (err) {
136
- console.error('Error subscribing');
137
- done();
138
- }
139
- });
140
- }, 1000);
118
+ helper.load([aedesNode, mqttNode], flow, function () {
119
+ const client1 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client1' });
120
+ const client2 = mqtt.connect('mqtt://localhost:1883', { clientId: 'client2' });
121
+ client1.on('error', function (err) {
122
+ console.error('Error: ', err.toString());
123
+ });
124
+ client1.on('connect', function () {
125
+ // console.log('External client1 connected');
126
+ client1.publish('test1883', 'test1', { retain: true }, function () {
127
+ // console.log('Published test1');
128
+ client1.publish('test1883', 'test2', { retain: true }, function () {
129
+ // console.log('Published test2');
130
+ client2.on('error', function (err) {
131
+ console.error('Error: ', err.toString());
132
+ });
133
+ client2.on('connect', function () {
134
+ // console.log('External client2 connected');
135
+ setTimeout(function () {
136
+ client2.subscribe('test1883', function (err, granted) {
137
+ // console.log('Subscription successful ' + JSON.stringify(granted));
138
+ if (err) {
139
+ console.error('Error subscribing');
140
+ done();
141
+ }
142
+ });
143
+ }, 1000);
144
+ });
141
145
  });
142
146
  });
143
- });
144
- });
145
- helper.load([aedesNode, mqttNode], flow, function () {
146
- const n2 = helper.getNode('n2');
147
+ }); const n2 = helper.getNode('n2');
147
148
  n2.on('input', function (msg) {
148
149
  // console.log('Broker received message topic: ' + msg.topic + ', clientid: ' + msg.payload.client.id);
149
150
  if (msg.topic === 'subscribe') {
@@ -22,7 +22,10 @@ describe('Aedes Broker TCP tests', function () {
22
22
  id: 'n1',
23
23
  type: 'aedes broker',
24
24
  mqtt_port: '1883',
25
- name: 'Aedes 1883'
25
+ name: 'Aedes 1883',
26
+ wires: [
27
+ [], []
28
+ ]
26
29
  }];
27
30
  helper.load(aedesNode, flow, function () {
28
31
  const n1 = helper.getNode('n1');
@@ -41,7 +44,7 @@ describe('Aedes Broker TCP tests', function () {
41
44
  mqtt_port: '1883',
42
45
  name: 'Aedes 1883',
43
46
  wires: [
44
- ['n2']
47
+ ['n2'], []
45
48
  ]
46
49
  },
47
50
  {
@@ -67,7 +70,8 @@ describe('Aedes Broker TCP tests', function () {
67
70
  msg.should.have.property('topic', 'clientReady');
68
71
  done();
69
72
  });
70
- });
73
+ }
74
+ );
71
75
  });
72
76
 
73
77
  it('a subscriber should receive a message from a publisher', function (done) {
@@ -79,7 +83,7 @@ describe('Aedes Broker TCP tests', function () {
79
83
  mqtt_port: '1883',
80
84
  name: 'Aedes 1883',
81
85
  wires: [
82
- ['n2']
86
+ ['n2'], []
83
87
  ]
84
88
  },
85
89
  {
@@ -137,7 +141,7 @@ describe('Aedes Broker TCP tests', function () {
137
141
  mqtt_port: '1883',
138
142
  name: 'Aedes 1883',
139
143
  wires: [
140
- ['n2']
144
+ ['n2'], []
141
145
  ]
142
146
  },
143
147
  {
@@ -161,7 +165,7 @@ describe('Aedes Broker TCP tests', function () {
161
165
  mqtt_port: '1884',
162
166
  name: 'Aedes 1884',
163
167
  wires: [
164
- ['n12']
168
+ ['n12'], []
165
169
  ]
166
170
  }, {
167
171
  id: 'n12',
@@ -209,12 +213,18 @@ describe('Aedes Broker TCP tests', function () {
209
213
  id: 'n1',
210
214
  type: 'aedes broker',
211
215
  mqtt_port: '1883',
212
- name: 'Aedes 1883'
216
+ name: 'Aedes 1883',
217
+ wires: [
218
+ [], []
219
+ ]
213
220
  }, {
214
221
  id: 'n11',
215
222
  type: 'aedes broker',
216
223
  mqtt_port: '1883',
217
- name: 'Aedes 1883 2'
224
+ name: 'Aedes 1883 2',
225
+ wires: [
226
+ [], []
227
+ ]
218
228
  }
219
229
  ],
220
230
  function () {
@@ -234,21 +244,21 @@ describe('Aedes Broker TCP tests', function () {
234
244
  mqtt_port: '1883',
235
245
  name: 'Aedes 1883',
236
246
  wires: [
237
- ['n2']
247
+ ['n2'], []
238
248
  ]
239
249
  },
240
250
  {
241
251
  id: 'n2',
242
252
  type: 'helper'
243
253
  }];
244
- const client = mqtt.connect('mqtt://localhost:1883', { clientId: 'client', resubscribe: false, reconnectPeriod: -1 });
245
- client.on('error', function (err) {
246
- console.error('Error: ', err.toString());
247
- });
248
- client.on('connect', function () {
249
- // console.log('External client connected');
250
- });
251
254
  helper.load(aedesNode, flow, function () {
255
+ const client = mqtt.connect('mqtt://localhost:1883', { clientId: 'client', resubscribe: false, reconnectPeriod: -1 });
256
+ client.on('error', function (err) {
257
+ console.error('Error: ', err.toString());
258
+ });
259
+ client.on('connect', function () {
260
+ // console.log('External client connected');
261
+ });
252
262
  const n2 = helper.getNode('n2');
253
263
  n2.on('input', function (msg) {
254
264
  msg.should.have.property('topic', 'clientReady');
@@ -268,7 +278,7 @@ describe('Aedes Broker TCP tests', function () {
268
278
  mqtt_port: '1883',
269
279
  name: 'Aedes 1883',
270
280
  wires: [
271
- ['n2']
281
+ ['n2'], []
272
282
  ]
273
283
  },
274
284
  {
@@ -294,14 +304,14 @@ describe('Aedes Broker TCP tests', function () {
294
304
  port: '1883'
295
305
  }
296
306
  ];
297
- const client = mqtt.connect('mqtt://localhost:1883', { clientId: 'client', resubscribe: false, reconnectPeriod: -1 });
298
- client.on('error', function (err) {
299
- console.error('Error: ', err.toString());
300
- });
301
- client.on('connect', function () {
302
- // console.log('External client connected');
303
- });
304
307
  helper.load([aedesNode, mqttNode], flow, function () {
308
+ const client = mqtt.connect('mqtt://localhost:1883', { clientId: 'client', resubscribe: false, reconnectPeriod: -1 });
309
+ client.on('error', function (err) {
310
+ console.error('Error: ', err.toString());
311
+ });
312
+ client.on('connect', function () {
313
+ // console.log('External client connected');
314
+ });
305
315
  const n2 = helper.getNode('n2');
306
316
  const n5 = helper.getNode('n5');
307
317
  n2.on('input', function (msg) {
@@ -26,13 +26,19 @@ describe('Aedes Broker Websocket tests', function () {
26
26
  type: 'aedes broker',
27
27
  mqtt_port: '1883',
28
28
  name: 'Aedes 1883',
29
- mqtt_ws_port: '8080'
29
+ mqtt_ws_port: '8080',
30
+ wires: [
31
+ [], []
32
+ ]
30
33
  }, {
31
34
  id: 'n11',
32
35
  type: 'aedes broker',
33
36
  mqtt_port: '1884',
34
37
  name: 'Aedes 1884',
35
- mqtt_ws_port: '8080'
38
+ mqtt_ws_port: '8080',
39
+ wires: [
40
+ [], []
41
+ ]
36
42
  }
37
43
  ],
38
44
  function () {
@@ -54,7 +60,7 @@ describe('Aedes Broker Websocket tests', function () {
54
60
  mqtt_ws_port: '8080',
55
61
  name: 'Aedes 1883',
56
62
  wires: [
57
- ['n2']
63
+ ['n2'], []
58
64
  ]
59
65
  },
60
66
  {
@@ -80,14 +86,14 @@ describe('Aedes Broker Websocket tests', function () {
80
86
  port: '1883'
81
87
  }
82
88
  ];
83
- const client = mqtt.connect('ws://localhost:8080', { clientId: 'client', resubscribe: false, reconnectPeriod: -1 });
84
- client.on('error', function (err) {
85
- console.error('Error: ', err.toString());
86
- });
87
- client.on('connect', function () {
88
- // console.log('External client connected');
89
- });
90
89
  helper.load([aedesNode, mqttNode], flow, function () {
90
+ const client = mqtt.connect('ws://localhost:8080', { clientId: 'client', resubscribe: false, reconnectPeriod: -1 });
91
+ client.on('error', function (err) {
92
+ console.error('Error: ', err.toString());
93
+ });
94
+ client.on('connect', function () {
95
+ // console.log('External client connected');
96
+ });
91
97
  const n2 = helper.getNode('n2');
92
98
  const n5 = helper.getNode('n5');
93
99
  n2.on('input', function (msg) {
@@ -116,7 +122,7 @@ describe('Aedes Broker Websocket tests', function () {
116
122
  mqtt_ws_path: '/mqtt',
117
123
  name: 'Aedes 1883',
118
124
  wires: [
119
- ['n2']
125
+ ['n2'], []
120
126
  ]
121
127
  },
122
128
  {