Switch HTTP Server

This commit is contained in:
iranl
2024-08-26 21:47:10 +02:00
parent d3c3589233
commit ca9c2feebc
234 changed files with 20090 additions and 8061 deletions

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env node
const EventSource = require('eventsource');
const url = 'http://192.168.2.131/events';
async function eventSourceClient() {
console.log(`Starting test`);
for (let i = 0; i < 1000000; i++)
{
if (i % 100 == 0)
console.log(`Count: ${i}`);
let eventSource = new EventSource(url);
eventSource.onopen = () => {
//console.log('EventSource connection opened.');
};
eventSource.onerror = (error) => {
console.error('EventSource error:', error);
// Close the connection on error
eventSource.close();
};
await new Promise((resolve) => {
eventSource.onmessage = (event) => {
//console.log('Received message:', event.data);
// Close the connection after receiving the first message
eventSource.close();
resolve();
}
});
}
}
eventSourceClient();