removed console log
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user