Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Aug 21, 2024
1 parent 3f6a83e commit 841a95b
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions benchmarks/websocket/server/echo.mjs
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
import worker_threads from "node:worker_threads";
import { cpus } from "node:os";
import url from "node:url";
import path from "node:path";
import uws from "uWebSockets.js";
import worker_threads from 'node:worker_threads' // eslint-disable-line
import { cpus } from 'node:os'
import url from 'node:url'
// import path from 'node:path'
import uws from 'uWebSockets.js'

var __filename = url.fileURLToPath(import.meta.url);
var __dirname = path.dirname(__filename);
const __filename = url.fileURLToPath(import.meta.url)
// const __dirname = path.dirname(__filename)

// eslint-disable-next-line
if (worker_threads.isMainThread) {
for (let i = cpus().length - 1; i >= 0; --i) {
new worker_threads.Worker(__filename);
// eslint-disable-next-line
new worker_threads.Worker(__filename)
}
} else {
const app = uws.App();
const app = uws.App()

app
.ws("/*", {
.ws('/*', {
compression: uws.DISABLED,
maxPayloadLength: 512 * 1024 * 1024,
maxBackpressure: 128 * 1024,
idleTimeout: 60,
message: (ws, message, isBinary) => {
/* Here we echo the message back, using compression if available */
const ok = ws.send(message, isBinary);
},
const ok = ws.send(message, isBinary) // eslint-disable-line
}
})
.get("/*", (res, req) => {
.get('/*', (res, req) => {
/* It does Http as well */
res
.writeStatus("200 OK")
.end("Hello there!");
.writeStatus('200 OK')
.end('Hello there!')
})
.listen(5001, (listenSocket) => {
if (listenSocket) {
// eslint-disable-next-line
if (worker_threads.threadId === 0) {
console.log("Listening to port 5001");
console.log('Listening to port 5001')
} else {
// eslint-disable-next-line
console.log(`Listening to port 5001 from thread ${worker_threads.threadId}`)
}
}
});
})
}

0 comments on commit 841a95b

Please sign in to comment.