first commit

This commit is contained in:
developertrinidad08
2023-01-16 18:11:14 -03:00
commit 7e6cf29479
233 changed files with 26791 additions and 0 deletions

View File

@ -0,0 +1,17 @@
{
"author": "",
"name": "serverstats",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "git://github.com/einaros/ws.git"
},
"engines": {
"node": ">0.4.0"
},
"dependencies": {
"express": "2.x"
},
"devDependencies": {},
"optionalDependencies": {}
}

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: Tahoma, Geneva, sans-serif;
}
div {
display: inline;
}
</style>
<script>
function updateStats(memuse) {
document.getElementById('rss').innerHTML = memuse.rss;
document.getElementById('heapTotal').innerHTML = memuse.heapTotal;
document.getElementById('heapUsed').innerHTML = memuse.heapUsed;
}
var host = window.document.location.host.replace(/:.*/, '');
var ws = new WebSocket('ws://' + host + ':8080');
ws.onmessage = function (event) {
updateStats(JSON.parse(event.data));
};
</script>
</head>
<body>
<strong>Server Stats</strong><br>
RSS: <div id='rss'></div><br>
Heap total: <div id='heapTotal'></div><br>
Heap used: <div id='heapUsed'></div><br>
</body>
</html>

19
node_modules/streamws/examples/serverstats/server.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
var WebSocketServer = require('../../').Server
, http = require('http')
, express = require('express')
, app = express.createServer();
app.use(express.static(__dirname + '/public'));
app.listen(8080);
var wss = new WebSocketServer({server: app});
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);
})
});