-
Notifications
You must be signed in to change notification settings - Fork 28
Add field/device specific subscribe, closes #9 and closes #8 #18
Conversation
I simplified the code and API. Both |
} | ||
this.ee.emit(topic, devId, payload); // full topic, including field if any | ||
this.ee.emit(parts.slice(0, 2).concat('+', parts.slice(3)).join('/'), devId, payload); // any device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want SDK users to work directly with our topic structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They don't, as you can see in on()
and off()
we translate their arguments to the topic that we only internally use as the eventName so that the above 2 emitted events reach the right listeners. See the client test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
client = new ttn.Client(BROKER); // don't pass appId and appAccessKey to the test broker | ||
client.appId = Math.floor(Math.random() * 16777215).toString(16); // but set random appId afterwards | ||
return client; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert tabs to spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
}); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert tabs to spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Closes #9 and #8
This also introduces Mocha/Should tests that run before every commit.
For the new API of
on('message')
andon('activation')
see the client testAlso,> Re-added to not break #2 / #19dev_id
andapp_id
are no longer added to the payload since the callbacks now get these via arguments.