Skip to content

Instantly share code, notes, and snippets.

@mikesurowiec
Last active July 23, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesurowiec/f1b07a91a9e7734942b9fa90646d9739 to your computer and use it in GitHub Desktop.
Save mikesurowiec/f1b07a91a9e7734942b9fa90646d9739 to your computer and use it in GitHub Desktop.
Shows how socket acts like a more standard REST api, with request / response
// Allows the client to get the data without having to wait for a new REQUEST_INTERVAL.
socket.on('getRealtimeDataForStations', (stations) => {
if (datastore.realtime && Array.isArray(stations)) {
stations.forEach((locationCode) => {
socket.emit(`realtime/${locationCode}`, datastore.realtime[locationCode]);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment