Skip to content

Commit

Permalink
fix: a 502 error and some other stuff adley found
Browse files Browse the repository at this point in the history
  • Loading branch information
azaleacolburn committed Dec 12, 2024
1 parent 4b4936a commit 47d22bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/routes/admin/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
match_key = '';
teams = ['', '', '', '', '', ''];
robot_queue = [];
};
const remove_scout = (scout_id: string) => {
Expand Down
13 changes: 6 additions & 7 deletions ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type ViteDevServer } from 'vite';
const info = (s: string) => console.log(`\x1b[32m ${s} \x1b[0m`);

const sid_to_username: Map<string, string> = new Map();
const robot_queue: [string, 'red' | 'blue'][] = [];
let robot_queue: [string, 'red' | 'blue'][] = [];
let curr_match_key: string = '';

const webSocketServer = {
Expand Down Expand Up @@ -56,16 +56,14 @@ const webSocketServer = {
socket.join('scout_queue');
return;
}
io.to('admin_room').emit('robot_left_queue', team_data);
io.to('admin_room').emit('robot_left_queue', team_data[0]);
socket.emit('time_to_scout', [curr_match_key, ...team_data]);
});

socket.on('leave_scout_queue', (scout_id: string) => {
const scout_sid = sid_to_username
.entries()
const scout_sid = Object.entries(sid_to_username)
.filter(([_sid, scout]) => scout === scout_id)
.map(([sid, _]) => sid)
.toArray()[0];
.map(([sid, _]) => sid)[0];
console.log(scout_sid);
// This event exist in the cast that the scout removed itself from the queue
io.emit('scout_left_queue', scout_id);
Expand All @@ -90,7 +88,8 @@ const webSocketServer = {

info(`${match_key}: ${teams}`);

const scout_queue = await io.in('scout_queue').fetchSockets();
robot_queue = [];
const scout_queue = (await io.in('scout_queue').fetchSockets()).reverse();
for (const socket of scout_queue) {
const team_data = teams.pop();
if (!team_data) break;
Expand Down

0 comments on commit 47d22bd

Please sign in to comment.