increase process priority instead of offloading to workers

This commit is contained in:
2025-01-22 15:00:32 +09:00
parent c4c7c921d7
commit 4f8dcebcd1
6 changed files with 45 additions and 16 deletions
+23
View File
@@ -0,0 +1,23 @@
import WebSocket from 'ws'
const numberOfClients = 10
const url = 'ws://localhost:1280/ws'
for (let i = 1; i <= numberOfClients; i++) {
const id = `${i}`
const websocket = new WebSocket(url)
websocket.onerror = () => websocket.close()
websocket.onopen = () => {
websocket.send(JSON.stringify({ action: 'join', id }))
console.log({ client: id, event: 'joined' })
}
websocket.onclose = () => {
console.log({ client: id, event: 'disconnected' })
}
websocket.onmessage = (event) => {
const byteSize = new Blob([event.data]).size
// console.log({ client: id, received: `${byteSize} B of data` })
}
}