Skip to content

Commit

Permalink
Calling client.end() when detaching the element
Browse files Browse the repository at this point in the history
This implements #14
  • Loading branch information
sandro-k committed Feb 9, 2016
1 parent fb2aaf5 commit 456593d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mqtt-connection.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@

},

_createdConnection: false,

observers: [
'_usernameOrPasswordChanged(username, options.username, password, options.password, withCredentials, auto)',
'_autoChanged(auto, withCredentials)'
Expand All @@ -280,6 +282,12 @@
}
},

detached: function () {
if (this._createdConnection && this.client){
this.disconnect();
}
},

_usernameChanged: function (username, old) {
this.set("options.username", username);
},
Expand Down Expand Up @@ -443,10 +451,13 @@
if (this.options.clientId && this.options.clientId.length == 0){
this.set("options.clientId", this._generateClientId());
}

this.options["queue"] = this.packetQueue;

this.client = mqtt.connect(this.url, this.options);
this.client.setMaxListeners(this.maxListeners);

this._createdConnection = true;
},

/**
Expand Down

0 comments on commit 456593d

Please sign in to comment.