Skip to content

Instantly share code, notes, and snippets.

@abobija
Created June 20, 2019 15:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abobija/771d824766bf2c56b256b9528542a0b0 to your computer and use it in GitHub Desktop.
Save abobija/771d824766bf2c56b256b9528542a0b0 to your computer and use it in GitHub Desktop.
WebSocket NodeJS Server written in YouTube video https://www.youtube.com/watch?v=_Z9Axfh6AEU
const app = require('express')();
const appWs = require('express-ws')(app);
app.ws('/echo', ws => {
ws.on('message', msg => {
console.log('Received: ', msg);
ws.send(msg);
});
});
app.listen(1337, () => console.log('Server has been started'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment