Skip to content

Commit

Permalink
whoops
Browse files Browse the repository at this point in the history
  • Loading branch information
wont-stream committed Dec 11, 2024
1 parent 73a55a1 commit 0129e0d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export default class extends EventEmitter {

const { buttons, timestamps, instance } = activity;

const metadata = { buttons_urls: [] };
const extra = { buttons: [] };
const metadata = { };
const extra = { };

if (buttons) {
metadata.buttons_urls = buttons.map((button) => button.url);
Expand Down
2 changes: 1 addition & 1 deletion src/transports/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parse } from "node:querystring";
const portRange = [6463, 6472];

const checkIfOpen = async (port) => {
new Promise((resolve) => {
return new Promise((resolve) => {
const ws = new WebSocket(`ws://localhost:${port}`);

ws.onopen = () => {
Expand Down
33 changes: 33 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

const portRange = [6463, 6472];

const checkIfOpen = async (port) => {
return new Promise((resolve) => {
const ws = new WebSocket(`ws://localhost:${port}`);

ws.onopen = () => {console.log(1)
ws.close();
resolve(true);
};

ws.onerror = () => {
resolve(false);
};
});
};

const getPort = async () => {
let port = portRange[0];

while (port <= portRange[1]) {
if (await checkIfOpen(port)) {
port++;
} else {
break;
}
}

return port;
};

console.log(await getPort());

0 comments on commit 0129e0d

Please sign in to comment.