0.1.4 • Published 9 years ago
barracks-messenger-sdk-betatest v0.1.4
Barracks Messaging SDK for Javascript (Beta)
The Javascript SDK to enable messaging on your devices
Installation
$ npm install barracks-messenger-sdk-betatestUsage
Create a Barracks Messaging SDK instance :
var BarracksMessenger = require('../src/index').BarracksMessenger;
var barracksMessenger = new BarracksMessenger({
apiKey: 'Your user API key',
unitId: 'The unique device identifier'
});Your user API key you can be found on the Account page of the Barracks application.
Connect to the messaging service :
barracksMessenger.connect({
onConnect: function() {
// Do something when your device connects to MQTT
},
onError: function(err) {
// Do something when an error occurs
},
onClose: function() {
// Do something when the connection is closed
},
onReconnect: function() {
// Do somethings when the device attempts to reconnect
}
});Subscribe to a topic to enable message reception :
barracksMessenger.subscribe(topic, function(messageReceived) {
// Do something with a message when you retrieve it
}, { qos: 1 });A message object has 5 properties :
- payload : String
- retained : boolean
- topic : String
- length : int
- qos : 0 or 1 (2 is not supported yet)
End the connection :
barracksMessenger.end();Docs & Community
- Website and Documentation
- Github Organization for other official SDKs
0.1.4
9 years ago
0.1.3
9 years ago
0.1.2
9 years ago
0.1.1
9 years ago
0.1.0
9 years ago
0.0.28
9 years ago
0.0.27
9 years ago
0.0.26
9 years ago
0.0.25
9 years ago
0.0.24
9 years ago
0.0.23
9 years ago
0.0.22
9 years ago
0.0.21
9 years ago
0.0.20
9 years ago
0.0.19
9 years ago
0.0.18
9 years ago
0.0.17
9 years ago
0.0.16
9 years ago
0.0.15
9 years ago
0.0.14
9 years ago
0.0.13
9 years ago
0.0.12
9 years ago
0.0.11
9 years ago
0.0.10
9 years ago
0.0.9
9 years ago
0.0.8
9 years ago
0.0.7
9 years ago
0.0.6
9 years ago
0.0.5
9 years ago
0.0.4
9 years ago
0.0.3
9 years ago
0.0.2
9 years ago
0.0.1
9 years ago