Created
November 26, 2017 19:29
-
-
Save eh3rrera/6a643e77d5dfdc6564b84921372f51ad to your computer and use it in GitHub Desktop.
Node.js script to publish location and heading events to Pusher every two seconds
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
const Pusher = require('pusher'); | |
const pusher = new Pusher({ | |
appId: 'YOUR_PUSHER_APP_', | |
key: 'YOUR_PUSHER_APP_KEY', | |
secret: 'YOUR_PUSHER_APP_SECRET', | |
cluster: 'YOUR_PUSHER_APP_CLUSTER', | |
encrypted: true | |
}); | |
const locations = [ | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""}, | |
{latitude: "", longitude: "-", heading: ""} | |
]; | |
locations.forEach((loc, index) => { | |
setTimeout(() => { | |
console.log(loc); | |
pusher.trigger('private-channel', 'client-new-location', loc); | |
}, 2000*index); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment