added force end transmition for dispatchers

This commit is contained in:
PxlLoewe
2025-05-30 22:47:02 -07:00
parent eaedd78202
commit 6950e24e54
13 changed files with 179 additions and 100 deletions

View File

@@ -62,6 +62,7 @@ export const handleConnectDispatch =
esimatedLogoutTime: parsedLogoffDate?.toISOString() || null,
lastHeartbeat: new Date().toISOString(),
userId: user.id,
zone: selectedZone,
loginTime: new Date().toISOString(),
},
});
@@ -72,20 +73,29 @@ export const handleConnectDispatch =
io.to("dispatchers").emit("dispatchers-update");
io.to("pilots").emit("dispatchers-update");
// dispatch-events
socket.on("ptt", async ({ shouldTransmit, channel }) => {
if (shouldTransmit) {
io.to("dispatchers").emit("other-ptt", {
publicUser: getPublicUser(user),
channel,
source: "Leitstelle",
socket.on("stop-other-transmition", async ({ ownRole, otherRole }) => {
const aircrafts = await prisma.connectedAircraft.findMany({
where: {
Station: {
bosCallsignShort: otherRole,
},
logoutTime: null,
},
include: {
Station: true,
},
});
const dispatchers = await prisma.connectedDispatcher.findMany({
where: {
zone: otherRole,
logoutTime: null,
},
});
[...aircrafts, ...dispatchers].forEach((entry) => {
io.to(`user:${entry.userId}`).emit("force-end-transmission", {
by: ownRole,
});
io.to("piots").emit("other-ptt", {
publicUser: getPublicUser(user),
channel,
source: "Leitstelle",
});
}
});
});
socket.on("disconnect", async () => {