-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
37 lines (30 loc) · 830 Bytes
/
test.js
File metadata and controls
37 lines (30 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*global console, require*/
var ef = require('./eventfabric'),
username = "admin",
password = "secret",
url = "http://localhost:8080/",
channel = "my.channel",
client = ef.client(username, password, url);
function onLoginSuccess (data) {
"use strict";
var value = {
"text": "cpu",
"percentage": Math.random() * 100
};
function onEventSent(status, data) {
var eventSent = JSON.parse(data);
console.log("event sent", status, eventSent);
}
function onEventFail (status, res) {
console.error("event error", status, res);
}
client.sendEvent({
value: value,
channel: channel
}, onEventSent, onEventFail);
}
function onLoginFail(err) {
"use strict";
console.error("login error", err);
}
client.login(onLoginSuccess, onLoginFail);