This repository is for an SDK to KloudDisplay
Created Dec 14th 2019 - Version 1.0.0
- Checkout the repository
- Navigate to the
klouddisplay-node-sdk
directory - Run
npm install
to install dependencies - Your SDK is now ready to be used
- Navigate to
test
directory - Run
node client.js
The SDK should connect to KloudDisplay server running on your host and interact with it (sending events, announcements etc).
- You need to have a valid account on KloudDisplay
- You need to get ID and SecretKey from your Account -> Settings -> Third Party Integration page
- You should have at least one KloudDisplay configured under your account
Using the SDK is pretty straight forward. Here is a sample code to import the SDK and connect to KloudDisplay
//1) Import KloudDisplay library (from wherever it is located)
var KLOUDDISPLAY = require('../lib/klouddisplay');
//2) Create a KloudDisplay client by providing the ID and SecretKey (can get one from your Account Settings page)
var displayclient = new KLOUDDISPLAY({
'host': '<your kloudspot instance baseurl>',
'id': '<your kloudspot clientID>',
'secretKey': '<your kloudspot clientSecret>'
});
//3) Send an event to KloudDisplay (Payload should contain appropriate parameters)
var eventPayload = {
"deviceId": "0a:0a:0a:00:00:27",
"age": 12,
"gender": "female"
};
displayclient.sendEvent(eventPayload, function(response) {
console.log(response);
});
//4) Or Send an announcement to KloudDisplay
var eventPayload = {
"terminals": [
"736f42f0921d456c8089c399b3ce915c"
],
"announcement": "Potential shooter in the building !!",
"priority": "critical",
"startTime" : moment().valueOf(),
"endTime" : moment().add(2, 'hours').valueOf(),
"location" : null
};
displayclient.sendAnnouncement(eventPayload, function(response) {
console.log(response);
});
//Tip: KloudDisplay SDK also supports Promises. The above call can also be accomplished like this:
displayclient.sendAnnouncement(eventPayload).then(function(response) {
console.log(response);
});
//Tip: If you are familiar with async/await, youc an wrap the above code inside of an async function and await on the result.
async function notifyEmergency() {
var response = await displayclient.sendAnnouncement(eventPayload);
//Do something with this response
console.log(response);
}
For any further questions on using the SDK, please contact -
- Uday Pyda (uday@kloudspot.com)