1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

restructure folders

This commit is contained in:
Rob Ede
2022-02-18 02:01:48 +00:00
parent 4d8573c3fe
commit cc3d356209
201 changed files with 52 additions and 49 deletions

View File

@ -0,0 +1,36 @@
const http = require('http')
let drop_goal = 5_000;
let dropped = 0;
let query = {
host: '127.0.0.1',
port: 8080,
path: '/events'
}
setInterval(() => {
if (dropped < drop_goal) {
let request = http.get(query, response => {
response.on('data', data => {
if (data.includes("data: connected\n")) {
// drop connection after welcome message
dropped += 1;
request.abort()
}
})
})
.on('error', () => {})
}
}, 1)
setInterval(() => {
http.get('http://127.0.0.1:8080/', () => print_status(true))
.setTimeout(100, () => print_status(false))
.on('error', () => {})
}, 20)
function print_status(accepting_connections) {
process.stdout.write("\r\x1b[K");
process.stdout.write(`Connections dropped: ${dropped}, accepting connections: ${accepting_connections}`);
}