Last active
December 13, 2015 17:48
-
-
Save nickharris/4950428 to your computer and use it in GitHub Desktop.
SensorData Insert Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Pusher = require('pusher'); | |
function insert(item, user, request) { | |
request.execute({ | |
success: function() { | |
// After the record has been inserted, trigger immediately to the client | |
request.respond(); | |
// Publish event for all other active clients | |
publishItemCreatedEvent(item); | |
} | |
}); | |
function publishItemCreatedEvent(item) { | |
// Ideally these settings would be taken from config | |
var pusher = new Pusher({ | |
appId: '36277', | |
key: '<replace with your Pusher key>', | |
secret: '<replace with your Pusher secret>' | |
}); | |
// Publish event on Pusher channel | |
pusher.trigger('sensor-updates', item.SensorID, item ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment