Created
January 4, 2019 23:18
-
-
Save robzhu/cca4710695f35cf63cefc4185b395c63 to your computer and use it in GitHub Desktop.
Local WebSocket Echo server
This file contains hidden or 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 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`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
maybe make port an argument with a default value of 8080?