Created
February 20, 2019 15:12
-
-
Save questsin/632ec4f83faaf92ba57d6130a8816792 to your computer and use it in GitHub Desktop.
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 ws = new WebSocket('wss://127.0.0.1'); | |
ws.on('open', function open() { | |
ws.send('something'); | |
}); | |
ws.on('message', function incoming(data) { | |
console.log(data); | |
}); |
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', function connection(ws) { | |
ws.on('message', function incoming(message) { | |
console.log('received: %s', message); | |
}); | |
ws.send('something'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment