Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
✨ deviceInfo -> client since _getDevice() resolves with the client an…
Browse files Browse the repository at this point in the history
…d not the deviceInfo
  • Loading branch information
ralphtheninja committed Apr 28, 2017
1 parent bc605a8 commit d39692f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -82,13 +82,13 @@ const Bridge = class Bridge extends EventEmitter {
this.emit('info', `${deviceId}: Handling message`)

this._getDevice(deviceId)
.then(deviceInfo => {
.then(client => {
const message = JSON.stringify(this._createMessage(deviceId, data))

deviceInfo.sendEvent(new device.Message(message), (err, res) => {
client.sendEvent(new device.Message(message), (err, res) => {
if (err) {
this.emit('error', `${deviceId}: Could not send event: ${err}. Closing connection`)
deviceInfo.close(err => {
client.close(err => {
// Delete reference even if close failed
delete this.devices[deviceId]
})
Expand Down

0 comments on commit d39692f

Please sign in to comment.