added other PTT info

This commit is contained in:
PxlLoewe
2025-05-21 14:52:38 -07:00
parent 64ce254239
commit c2799fbb49
3 changed files with 31 additions and 20 deletions

View File

@@ -4,31 +4,33 @@ import { Socket, Server } from "socket.io";
export const handleConnectDesktop = (socket: Socket, io: Server) => () => {
const user = socket.data.user as User;
const connectedAircraft = prisma.connectedAircraft.findFirst({
where: {
userId: user.id,
logoutTime: null,
},
include: {
Station: true,
},
});
const conenctedDispatchers = prisma.connectedDispatcher.findFirst({
where: {
userId: user.id,
logoutTime: null,
},
})
socket.join(`user:${user.id}`);
socket.join(`desktop:${user.id}`);
socket.on("ptt", (data) => {
socket.on("ptt", async (data) => {
socket.to(`user:${user.id}`).emit("ptt", data);
const connectedAircraft = await prisma.connectedAircraft.findFirst({
where: {
userId: user.id,
logoutTime: null,
},
include: {
Station: true,
},
});
const connectedDispatcher = await prisma.connectedDispatcher.findFirst({
where: {
userId: user.id,
logoutTime: null,
},
});
socket.to("pilots").emit("other-ptt", {
publicUser: user.publicId,
source:
})
source:
connectedAircraft?.Station.bosCallsignShort || connectedDispatcher
? "Leitstelle"
: user.publicId,
});
});
};