From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../node-ws/examples/server-stats/index.js | 33 ++++++++++++ .../node-ws/examples/server-stats/package.json | 9 ++++ .../examples/server-stats/public/index.html | 63 ++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 testing/xpcshell/node-ws/examples/server-stats/index.js create mode 100644 testing/xpcshell/node-ws/examples/server-stats/package.json create mode 100644 testing/xpcshell/node-ws/examples/server-stats/public/index.html (limited to 'testing/xpcshell/node-ws/examples/server-stats') diff --git a/testing/xpcshell/node-ws/examples/server-stats/index.js b/testing/xpcshell/node-ws/examples/server-stats/index.js new file mode 100644 index 0000000000..e8754b5b28 --- /dev/null +++ b/testing/xpcshell/node-ws/examples/server-stats/index.js @@ -0,0 +1,33 @@ +'use strict'; + +const express = require('express'); +const path = require('path'); +const { createServer } = require('http'); + +const { WebSocketServer } = require('../..'); + +const app = express(); +app.use(express.static(path.join(__dirname, '/public'))); + +const server = createServer(app); +const wss = new WebSocketServer({ server }); + +wss.on('connection', function (ws) { + const 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); + }); +}); + +server.listen(8080, function () { + console.log('Listening on http://localhost:8080'); +}); diff --git a/testing/xpcshell/node-ws/examples/server-stats/package.json b/testing/xpcshell/node-ws/examples/server-stats/package.json new file mode 100644 index 0000000000..20e2029133 --- /dev/null +++ b/testing/xpcshell/node-ws/examples/server-stats/package.json @@ -0,0 +1,9 @@ +{ + "author": "", + "name": "serverstats", + "version": "0.0.0", + "repository": "websockets/ws", + "dependencies": { + "express": "^4.16.4" + } +} diff --git a/testing/xpcshell/node-ws/examples/server-stats/public/index.html b/testing/xpcshell/node-ws/examples/server-stats/public/index.html new file mode 100644 index 0000000000..a82815af6f --- /dev/null +++ b/testing/xpcshell/node-ws/examples/server-stats/public/index.html @@ -0,0 +1,63 @@ + + + + + Server stats + + + +

Server stats

+ + + + + + + + + + + + + + + + + + + + + + + + +
Memory usage
RSS
Heap total
Heap used
External
+ + + -- cgit v1.2.3