File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
const mqtt = require ( 'mqtt' )
2
2
3
3
class Hub {
4
- constructor ( accountID , apiKey , options ) {
4
+ constructor ( accountID , apiKey , deviceID , options ) {
5
5
this . accountID = accountID
6
6
this . apiKey = apiKey
7
+ this . deviceID = this . _normalizeDeviceID ( deviceID )
7
8
this . handlers = { }
8
9
this . options = options || { }
9
10
}
10
11
12
+ _normalizeDeviceID ( id ) {
13
+ return `${ this . accountID } :${ id } `
14
+ }
15
+
11
16
_normalizeTopic ( topic ) {
12
17
return `${ this . accountID } /${ topic } `
13
18
}
@@ -19,7 +24,8 @@ class Hub {
19
24
connect ( handler ) {
20
25
this . client = mqtt . connect ( 'mqtt://hub.labstack.com' , {
21
26
username : this . accountID ,
22
- password : this . apiKey
27
+ password : this . apiKey ,
28
+ clientId : this . deviceID
23
29
} )
24
30
this . client . on ( 'connect' , function ( ) {
25
31
if ( handler ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " labstack" ,
3
- "version" : " 0.32.0 " ,
3
+ "version" : " 0.32.1 " ,
4
4
"description" : " Official Node.js client library for the LabStack platform" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
You can’t perform that action at this time.
0 commit comments