Skip to content

Instantly share code, notes, and snippets.

@devarajchidambaram
Created February 27, 2019 05:12
Show Gist options
  • Save devarajchidambaram/89ccd0204561dc650ec510d273173153 to your computer and use it in GitHub Desktop.
Save devarajchidambaram/89ccd0204561dc650ec510d273173153 to your computer and use it in GitHub Desktop.
web socket server
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('messsage received: %s', message);
});
setInterval(function(){
ws.send('send notifications 5 secs once');
}, 5000)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment