removed console log

This commit is contained in:
PxlLoewe
2025-05-24 12:50:58 -07:00
parent 1d78d455fc
commit cbeae274a4
2 changed files with 7 additions and 26 deletions

View File

@@ -3,24 +3,15 @@ import { Server, Socket } from "socket.io";
export const handleConnectDispatch =
(socket: Socket, io: Server) =>
async ({
logoffTime,
selectedZone,
}: {
logoffTime: string;
selectedZone: string;
}) => {
async ({ logoffTime, selectedZone }: { logoffTime: string; selectedZone: string }) => {
try {
const user: User = socket.data.user; // User ID aus dem JWT-Token
console.log("User connected to dispatch server");
if (!user) return Error("User not found");
console.log("Disponent connected:", user.publicId);
if (!user.permissions?.includes("DISPO")) {
socket.emit(
"error",
"You do not have permission to connect to the dispatch server.",
);
socket.emit("error", "You do not have permission to connect to the dispatch server.");
return;
}
@@ -32,9 +23,7 @@ export const handleConnectDispatch =
});
if (existingConnection) {
await io
.to(`user:${user.id}`)
.emit("force-disconnect", "double-connection");
await io.to(`user:${user.id}`).emit("force-disconnect", "double-connection");
await prisma.connectedDispatcher.updateMany({
where: {
userId: user.id,
@@ -100,7 +89,6 @@ export const handleConnectDispatch =
});
socket.on("disconnect", async () => {
console.log("Disconnected from dispatch server");
await prisma.connectedDispatcher.update({
where: {
id: connectedDispatcherEntry.id,
@@ -112,11 +100,7 @@ export const handleConnectDispatch =
io.to("dispatchers").emit("dispatchers-update");
io.to("pilots").emit("dispatchers-update");
});
socket.on("reconnect", async () => {
console.log("Reconnected to dispatch server");
});
} catch (error) {
console.error("Error connecting to dispatch server:", error);
console.log("Error connecting to dispatch server:", error);
}
};

View File

@@ -1,4 +1,4 @@
import { getPublicUser, prisma } from "@repo/db";
import { getPublicUser, prisma, User } from "@repo/db";
import { channel } from "diagnostics_channel";
import { Server, Socket } from "socket.io";
@@ -6,7 +6,7 @@ export const handleConnectPilot =
(socket: Socket, io: Server) =>
async ({ logoffTime, stationId }: { logoffTime: string; stationId: string }) => {
try {
const user = socket.data.user; // User ID aus dem JWT-Token
const user: User = socket.data.user; // User ID aus dem JWT-Token
const userId = socket.data.user.id; // User ID aus dem JWT-Token
const Station = await prisma.station.findFirst({
@@ -14,10 +14,10 @@ export const handleConnectPilot =
id: parseInt(stationId),
},
});
console.log("Pilot connected:", userId);
if (!user) return Error("User not found");
console.log("Pilot connected:", user.publicId);
const existingConnection = await prisma.connectedAircraft.findFirst({
where: {
userId: user.id,
@@ -73,8 +73,6 @@ export const handleConnectPilot =
socket.join(`user:${userId}`); // Join the user-specific room
socket.join(`station:${stationId}`); // Join the station-specific room
console.log(`Pilot in: station:${stationId}`);
io.to("dispatchers").emit("pilots-update");
io.to("pilots").emit("pilots-update");
@@ -100,7 +98,6 @@ export const handleConnectPilot =
});
socket.on("disconnect", async () => {
console.log("Disconnected from dispatch server");
await prisma.connectedAircraft
.update({
where: {