Comparing version 0.2.8 to 0.2.9
@@ -83,3 +83,9 @@ (function (global, factory) { | ||
this.apiToken = config['auth-token']; | ||
this.mqttConfig.clientId = "a:" + config.org + ":" + config.id; | ||
//support for shared subscription | ||
this.shared = (config['type'] + '').toLowerCase() === "shared" || false; | ||
if (this.shared) { | ||
this.mqttConfig.clientId = "A:" + config.org + ":" + config.id; | ||
} else { | ||
this.mqttConfig.clientId = "a:" + config.org + ":" + config.id; | ||
} | ||
this.subscriptions = []; | ||
@@ -86,0 +92,0 @@ |
{ | ||
"name": "ibmiotf", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "A library for developing device and application clients for IBM Internet of Things Foundation", | ||
@@ -5,0 +5,0 @@ "main": "dist/iotf-client.js", |
@@ -261,2 +261,3 @@ Node.js Client Library | ||
- auth-token - API key token | ||
- type - use 'shared' to enable shared subscription | ||
@@ -322,3 +323,30 @@ If you want to use quickstart, then send only the first two properties. | ||
Shared Subscription | ||
--------------------- | ||
Use this feature to build scalable applications which will load balance messages across multiple instances of the application. To enable this, pass 'type' as 'shared' in the configuration. | ||
``` {.sourceCode .javascript} | ||
var appClientConfig = { | ||
org: 'xxxxx', | ||
id: 'myapp', | ||
"auth-key": 'a-xxxxxx-xxxxxxxxx', | ||
"auth-token": 'xxxxx!xxxxxxxx', | ||
"type" : "shared" // make this connection as shared subscription | ||
}; | ||
var appClient = new Client.IotfApplication(appClientConfig); | ||
appClient.connect(); | ||
appClient.on("connect", function () { | ||
//Add your code here | ||
}); | ||
appClient.on("error", function (err) { | ||
console.log("Error : "+err); | ||
}); | ||
.... | ||
``` | ||
Handling errors | ||
@@ -325,0 +353,0 @@ ------------------ |
@@ -52,3 +52,9 @@ /** | ||
this.apiToken = config['auth-token']; | ||
this.mqttConfig.clientId = "a:" + config.org + ":" + config.id; | ||
//support for shared subscription | ||
this.shared = ((config['type']+'').toLowerCase() === "shared") || false; | ||
if(this.shared) { | ||
this.mqttConfig.clientId = "A:" + config.org + ":" + config.id; | ||
} else { | ||
this.mqttConfig.clientId = "a:" + config.org + ":" + config.id; | ||
} | ||
this.subscriptions = []; | ||
@@ -55,0 +61,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1180921
25
22181
654