Skip to content

Commit 70adb15

Browse files
committed
Emit 'disconnect' on client disconnections.
1 parent f6c2595 commit 70adb15

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/mqtt.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ Cayenne.prototype.connect = function(callback) {
4848
return callback(null, self.client);
4949
});
5050

51+
this.client.on('close', function () {
52+
self.emit("disconnect");
53+
});
54+
5155
this.client.on('message', self.onMessage.bind(self));
5256

57+
58+
5359
const cmdTopic = apiVersion + '/:username/'+THINGS+'/:thingId/cmd/:channel';
5460
Router.addRoute(cmdTopic, this.handleCommand.bind(this));
5561

0 commit comments

Comments
 (0)