Comparing version 0.2.29 to 0.2.30
@@ -71,2 +71,3 @@ (function (global, factory) { | ||
var DM_ACTION_RE = /^iotdm-1\/mgmt\/initiate\/(.+)\/(.+)$/; | ||
var DM_CUSTOM_ACTION_RE = /^iotdm-1\/mgmt\/custom\/(.+)\/(.+)$/; | ||
@@ -155,3 +156,3 @@ var ManagedDeviceClient = (function (_DeviceClient) { | ||
key: 'manage', | ||
value: function manage(lifetime, supportDeviceActions, supportFirmwareActions) { | ||
value: function manage(lifetime, supportDeviceActions, supportFirmwareActions, extensions) { | ||
if (!this.isConnected) { | ||
@@ -178,3 +179,3 @@ this.log.error("Client is not connected"); | ||
if ((0, _utilUtilJs.isDefined)(supportDeviceActions) || (0, _utilUtilJs.isDefined)(supportFirmwareActions)) { | ||
if ((0, _utilUtilJs.isDefined)(supportDeviceActions) || (0, _utilUtilJs.isDefined)(supportFirmwareActions) || (0, _utilUtilJs.isDefined)(extensions)) { | ||
d.supports = new Object(); | ||
@@ -198,2 +199,12 @@ | ||
} | ||
if ((0, _utilUtilJs.isDefined)(extensions)) { | ||
if (!Array.isArray(extensions)) { | ||
throw new Error("extensions must be an array"); | ||
} | ||
var i; | ||
for (i = 0; i < extensions.length; i++) { | ||
d.supports[extensions[i]] = true; | ||
} | ||
} | ||
} | ||
@@ -715,2 +726,8 @@ | ||
} | ||
} else { | ||
match = DM_CUSTOM_ACTION_RE.exec(topic); | ||
if (match) { | ||
var action = match[2]; | ||
this.emit('dmAction', { reqId: reqId, action: action }); | ||
} | ||
} | ||
@@ -717,0 +734,0 @@ |
{ | ||
"name": "ibmiotf", | ||
"version": "0.2.29", | ||
"version": "0.2.30", | ||
"description": "A library for developing device and application clients for IBM Watson IoT Platform", | ||
@@ -5,0 +5,0 @@ "main": "dist/iotf-client.js", |
Node.js Client Library | ||
======================== | ||
The node.js client is used for simplifying the interacting with the IBM Watson Internet of Things Platform. The following libraries contain instructions and guidance on using the nodejs ibmiotf node to interact with devices and applications within your organizations. | ||
The node.js client is used for simplifying the interaction with the IBM Watson Internet of Things Platform. The following libraries contain instructions and guidance on using the nodejs ibmiotf node to interact with devices and applications within your organizations. | ||
@@ -26,3 +26,3 @@ This client library is divided into three parts, Device, ManagedDevice and Application. The Devices section contains information on how devices publish events and handle commands using the nodejs ibmiotf module, ManagedDevice section contains information on how you can manage the device. More information on device management can be found [here.](https://docs.internetofthings.ibmcloud.com/reference/device_mgmt.html). The Applications section contains information on how applications can use the nodejs ibmiotf module to interact with devices. | ||
======= | ||
Load the library in node.js / browserify | ||
Load the library in node.js | ||
------------------------------------------- | ||
@@ -34,11 +34,12 @@ | ||
**Note:** When this client library is used in the Node.js environment, it will use tcp/tls. But if user wants to use websockets in Node.js, the user must add a new property `enforce-ws` in the configuration. | ||
Load the library in browser | ||
------------------------------ | ||
load `iotf-client-bundle.js` or `iotf-client-bundle-min.js` from the `dist` directory | ||
load `iotf-client-bundle.js` or `iotf-client-bundle-min.js` from the `dist` directory. Check out the [sample](https://github.com/ibm-watson-iot/iot-nodejs/tree/master/samples/WebApplicationSample) here. | ||
**Note:** Library used in Node.js will use tcp/ssl and websockets when the library is used in browser. But if user wants to use websockets in Node.js, the user must add a new property `enforce-ws` in the configuration. | ||
Devices | ||
@@ -45,0 +46,0 @@ =============================== |
@@ -47,2 +47,3 @@ /** | ||
const DM_ACTION_RE = /^iotdm-1\/mgmt\/initiate\/(.+)\/(.+)$/; | ||
const DM_CUSTOM_ACTION_RE = /^iotdm-1\/mgmt\/custom\/(.+)\/(.+)$/; | ||
@@ -123,3 +124,3 @@ export default class ManagedDeviceClient extends DeviceClient { | ||
manage(lifetime, supportDeviceActions, supportFirmwareActions){ | ||
manage(lifetime, supportDeviceActions, supportFirmwareActions, extensions){ | ||
if(!this.isConnected){ | ||
@@ -146,3 +147,3 @@ this.log.error("Client is not connected"); | ||
if(isDefined(supportDeviceActions) || isDefined(supportFirmwareActions)){ | ||
if(isDefined(supportDeviceActions) || isDefined(supportFirmwareActions) || isDefined(extensions)){ | ||
d.supports = new Object(); | ||
@@ -166,2 +167,12 @@ | ||
} | ||
if (isDefined(extensions)) { | ||
if (!Array.isArray(extensions)) { | ||
throw new Error("extensions must be an array"); | ||
} | ||
var i; | ||
for (i=0; i<extensions.length; i++) { | ||
d.supports[extensions[i]] = true; | ||
} | ||
} | ||
} | ||
@@ -669,2 +680,8 @@ | ||
} | ||
} else { | ||
match = DM_CUSTOM_ACTION_RE.exec(topic); | ||
if (match) { | ||
var action = match[2]; | ||
this.emit('dmAction', { reqId: reqId, action: action}); | ||
} | ||
} | ||
@@ -758,2 +775,2 @@ | ||
} | ||
} |
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
1487801
53
27718
972