compatibility: add node.js example server

This commit is contained in:
Benjamin Sergeant 2020-02-26 12:17:34 -08:00
parent 5ce1a596cf
commit a42f115f79
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,11 @@
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');
});

View File

@ -0,0 +1,11 @@
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080, perMessageDeflate: true });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});