Revision 2f2b3e8f8417c799fd579ced1a3e89f9a18fbb1c authored by Luigi Pinca on 26 May 2021, 19:20:45 UTC, committed by Luigi Pinca on 26 May 2021, 19:21:11 UTC
1 parent c05d51f
Raw File
autobahn-server.js
'use strict';

const WebSocket = require('../');

const port = process.argv.length > 2 ? parseInt(process.argv[2]) : 9001;
const wss = new WebSocket.Server({ port }, () => {
  console.log(
    `Listening to port ${port}. Use extra argument to define the port`
  );
});

wss.on('connection', (ws) => {
  ws.on('message', (data) => ws.send(data));
  ws.on('error', (e) => console.error(e));
});
back to top