Skip to content

Instantly share code, notes, and snippets.

@robzhu
Created January 4, 2019 23:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robzhu/cca4710695f35cf63cefc4185b395c63 to your computer and use it in GitHub Desktop.
Save robzhu/cca4710695f35cf63cefc4185b395c63 to your computer and use it in GitHub Desktop.
Local WebSocket Echo server
const WebSocket = require('ws');
const wss = new WebSocket.Server({port: 8080});
wss.on('connection', socket => {
socket.on('message', data => {
socket.send(data);
});
});
console.log(`Listening on ws://localhost:8080`);
@ranman
Copy link

ranman commented Jan 8, 2019

maybe make port an argument with a default value of 8080?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment