added last talking info to Audio Pannel

This commit is contained in:
PxlLoewe
2025-05-21 15:20:04 -07:00
parent c2799fbb49
commit f22335b1bf
6 changed files with 82 additions and 16 deletions

View File

@@ -1,13 +1,18 @@
import { prisma, User } from "@repo/db";
import { getPublicUser, prisma, User } from "@repo/db";
import { Socket, Server } from "socket.io";
interface PTTData {
shouldTransmit: boolean;
source: string;
}
export const handleConnectDesktop = (socket: Socket, io: Server) => () => {
const user = socket.data.user as User;
socket.join(`user:${user.id}`);
socket.join(`desktop:${user.id}`);
socket.on("ptt", async (data) => {
socket.on("ptt", async (data: PTTData) => {
socket.to(`user:${user.id}`).emit("ptt", data);
const connectedAircraft = await prisma.connectedAircraft.findFirst({
where: {
@@ -25,12 +30,16 @@ export const handleConnectDesktop = (socket: Socket, io: Server) => () => {
logoutTime: null,
},
});
socket.to("pilots").emit("other-ptt", {
publicUser: user.publicId,
const otherPttData = {
publicUser: getPublicUser(user),
source:
connectedAircraft?.Station.bosCallsignShort || connectedDispatcher
? "Leitstelle"
: user.publicId,
});
};
if (data.shouldTransmit) {
socket.to("pilots").emit("other-ptt", otherPttData);
socket.to("pilots").emit("other-ptt", otherPttData);
}
});
};