Skip to content

Instantly share code, notes, and snippets.

@questsin
Created February 20, 2019 15:12
Show Gist options
  • Save questsin/632ec4f83faaf92ba57d6130a8816792 to your computer and use it in GitHub Desktop.
Save questsin/632ec4f83faaf92ba57d6130a8816792 to your computer and use it in GitHub Desktop.
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);
});
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