Skip to content

Commit eeffb63

Browse files
HTTP transport implementation
1 parent ffe7f16 commit eeffb63

23 files changed

+1481
-89
lines changed

.babelrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

index-browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.DeviceHive = require('./src/DeviceHive');

index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,24 @@ const httpDeviceHive = new DeviceHive({
1010
pluginServiceURL: 'http://localhost:8110/dh/rest'
1111
});
1212

13-
httpDeviceHive.connect();
13+
const CommandPollQuery = DeviceHive.models.CommandPollQuery;
14+
const query = new CommandPollQuery({
15+
deviceId: 'e50d6085-2aba-48e9-b1c3-73c673e414be',
16+
names: 'test'
17+
});
18+
19+
let subscriptionId;
20+
21+
httpDeviceHive.on(`message`, (message) => {
22+
console.log(message);
23+
});
24+
25+
httpDeviceHive.connect()
26+
.then((httpDeviceHive) => httpDeviceHive.command.subscribe(query))
27+
.then((data) => subscriptionId = data.subscriptionId)
28+
.catch((error) => console.warn(error));
1429

30+
setTimeout(() => {
31+
httpDeviceHive.command.unsubscribe(subscriptionId)
32+
.then((data) => subscriptionId = data.subscriptionId)
33+
}, 10000);

0 commit comments

Comments
 (0)