increase process priority instead of offloading to workers
This commit is contained in:
@@ -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` })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user