added auto disconnect when changing link

This commit is contained in:
PxlLoewe
2025-06-02 15:04:15 -07:00
parent 72998a36a4
commit af36b82221
9 changed files with 72 additions and 5 deletions

View File

@@ -70,6 +70,7 @@ export const handleConnectDispatch =
socket.join("dispatchers"); // Dem Dispatcher-Raum beitreten
socket.join(`user:${user.id}`); // Dem User-Raum beitreten
io.to(`user:${user.id}`).emit("dispatchers-update", connectedDispatcherEntry);
io.to("dispatchers").emit("dispatchers-update");
io.to("pilots").emit("dispatchers-update");

View File

@@ -6,6 +6,7 @@ export const handleConnectPilot =
(socket: Socket, io: Server) =>
async ({ logoffTime, stationId }: { logoffTime: string; stationId: string }) => {
try {
if (!stationId) return Error("Station ID is required");
const user: User = socket.data.user; // User ID aus dem JWT-Token
const userId = socket.data.user.id; // User ID aus dem JWT-Token