File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 11const mqtt = require ( 'mqtt' )
22
33class Hub {
4- constructor ( accountID , apiKey , options ) {
4+ constructor ( accountID , apiKey , deviceID , options ) {
55 this . accountID = accountID
66 this . apiKey = apiKey
7+ this . deviceID = this . _normalizeDeviceID ( deviceID )
78 this . handlers = { }
89 this . options = options || { }
910 }
1011
12+ _normalizeDeviceID ( id ) {
13+ return `${ this . accountID } :${ id } `
14+ }
15+
1116 _normalizeTopic ( topic ) {
1217 return `${ this . accountID } /${ topic } `
1318 }
@@ -19,7 +24,8 @@ class Hub {
1924 connect ( handler ) {
2025 this . client = mqtt . connect ( 'mqtt://hub.labstack.com' , {
2126 username : this . accountID ,
22- password : this . apiKey
27+ password : this . apiKey ,
28+ clientId : this . deviceID
2329 } )
2430 this . client . on ( 'connect' , function ( ) {
2531 if ( handler ) {
Original file line number Diff line number Diff line change 11{
22 "name" : " labstack" ,
3- "version" : " 0.32.0 " ,
3+ "version" : " 0.32.1 " ,
44 "description" : " Official Node.js client library for the LabStack platform" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments