Simulator nicht verbunden warnung

This commit is contained in:
PxlLoewe
2025-06-27 21:40:23 -07:00
parent a2db875569
commit dc92174798
12 changed files with 114 additions and 16 deletions

View File

@@ -5,7 +5,15 @@ import { Server, Socket } from "socket.io";
export const handleConnectPilot =
(socket: Socket, io: Server) =>
async ({ logoffTime, stationId }: { logoffTime: string; stationId: string }) => {
async ({
logoffTime,
stationId,
debug,
}: {
logoffTime: string;
stationId: string;
debug: boolean;
}) => {
try {
if (!stationId) return Error("Station ID is required");
const user: User = socket.data.user; // User ID aus dem JWT-Token
@@ -78,8 +86,7 @@ export const handleConnectPilot =
return { lat, lng };
}
const randomPos =
process.env.environment === "development" ? getRandomGermanPosition() : undefined;
const randomPos = debug ? getRandomGermanPosition() : undefined;
const connectedAircraftEntry = await prisma.connectedAircraft.create({
data: {
@@ -87,8 +94,7 @@ export const handleConnectPilot =
esimatedLogoutTime: parsedLogoffDate?.toISOString() || null,
userId: userId,
stationId: parseInt(stationId),
lastHeartbeat:
process.env.environment === "development" ? nowPlus2h.toISOString() : undefined,
lastHeartbeat: debug ? nowPlus2h.toISOString() : undefined,
posLat: randomPos?.lat,
posLng: randomPos?.lng,
},