comunicationLeap/node_modules/ws/test/autobahn-server.js
node_modules/ws/test/autobahn-server.jsRaw
1var WebSocketServer = require('../').Server;
2
3process.on('uncaughtException', function(err) {
4 console.log('Caught exception: ', err, err.stack);
5});
6
7process.on('SIGINT', function () {
8 try {
9 console.log('Updating reports and shutting down');
10 var ws = new WebSocket('ws://localhost:9001/updateReports?agent=ws');
11 ws.on('close', function() {
12 process.exit();
13 });
14 }
15 catch(e) {
16 process.exit();
17 }
18});
19
20var wss = new WebSocketServer({port: 8181});
21wss.on('connection', function(ws) {
22 console.log('new connection');
23 ws.on('message', function(data, flags) {
24 ws.send(flags.buffer, {binary: flags.binary === true});
25 });
26 ws.on('error', function() {
27 console.log('error', arguments);
28 });
29});