Droopy IOT Events
Realtime device communication built on top of PubNub.
Installation
npm install droopy-iot
Node.js
var droopyIot = ;
Browser
Just include /dist/droopyIot.js
on your page. This will give you window.droopyIot
Example Usage
For more complete example, check out the demos.
var iot = droopyIot;iotiot; // Even supports direct request and responseiot
API
droopyIot.register(deviceId)
Initial setup method
var iot = droopyIot;
trigger(key, payload, targetDevice)
Sends an event to the targeted device
iot
subscribe(key, handler)
Attaches a function handler to the specified key. You will only handle events with a matching target device
var handlers = { // use payload.state to set GPIO pin };iot;
unsubscribe(key, handler)
Removes a function handler
iot;
request(key, payload, targetDevice)
Sends a request to a targeted device and returns a promise that will be resolved
when the targeted device responds. The targeted subscriber can respond
with event.respond(payload)
// If we had a web server asking the status of a light in the basement...var webServerIot = droopyIot;webServerIotiot; //This is what the raspberry pi in the basement would look likevar basementIot = droopyIot;basementIot;