File: connected-users-websocket/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/examples/serverstats-express_3/server.js

Recommend this page to a friend!
  Classes of Igor Escobar   Terminal Crossword   connected-users-websocket/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/examples/serverstats-express_3/server.js   Download  
File: connected-users-websocket/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/examples/serverstats-express_3/server.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Terminal Crossword
Generate a crosswords board on a text console
Author: By
Last change:
Date: 2 years ago
Size: 606 bytes
 

Contents

Class file image Download
var WebSocketServer = require('../../').Server , http = require('http') , express = require('express') , app = express(); app.use(express.static(__dirname + '/public')); var server = http.createServer(app); server.listen(8080); var wss = new WebSocketServer({server: server}); wss.on('connection', function(ws) { var id = setInterval(function() { ws.send(JSON.stringify(process.memoryUsage()), function() { /* ignore errors */ }); }, 100); console.log('started client interval'); ws.on('close', function() { console.log('stopping client interval'); clearInterval(id); }) });