continue dispatch-server

This commit is contained in:
PxlLoewe
2025-03-14 00:18:06 -07:00
parent ec335ce489
commit 05b7d0fd39
14 changed files with 179 additions and 22 deletions

View File

@@ -1,8 +1,14 @@
import { pubClient } from "modules/redis";
import { Server, Socket } from "socket.io";
export const handle = async (socket: Socket, io: Server) => {
console.log("Connected to dispatch server");
socket.on("disconnect", () => {
export const handle = (socket: Socket, io: Server) => async (jwt: string) => {
const userId = socket.data.user.id; // User ID aus dem JWT-Token
await pubClient.set(`dispatchers:${socket.id}`, userId);
socket.join("dispatchers"); // Dem Dispatcher-Raum beitreten
socket.on("disconnect", async () => {
console.log("Disconnected from dispatch server");
await pubClient.del(`dispatchers:${socket.id}`);
});
};