You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
575 B

  1. var WebSocketServer = require('../../').Server
  2. , http = require('http')
  3. , express = require('express')
  4. , app = express.createServer();
  5. app.use(express.static(__dirname + '/public'));
  6. app.listen(8080);
  7. var wss = new WebSocketServer({server: app});
  8. wss.on('connection', function(ws) {
  9. var id = setInterval(function() {
  10. ws.send(JSON.stringify(process.memoryUsage()), function() { /* ignore errors */ });
  11. }, 100);
  12. console.log('started client interval');
  13. ws.on('close', function() {
  14. console.log('stopping client interval');
  15. clearInterval(id);
  16. })
  17. });