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,7 +4,12 @@ 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({
socket.join(`user:${user.id}`);
socket.join(`desktop:${user.id}`);
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,
@@ -14,21 +19,18 @@ export const handleConnectDesktop = (socket: Socket, io: Server) => () => {
},
});
const conenctedDispatchers = prisma.connectedDispatcher.findFirst({
const connectedDispatcher = await prisma.connectedDispatcher.findFirst({
where: {
userId: user.id,
logoutTime: null,
},
})
socket.join(`user:${user.id}`);
socket.join(`desktop:${user.id}`);
socket.on("ptt", (data) => {
socket.to(`user:${user.id}`).emit("ptt", data);
});
socket.to("pilots").emit("other-ptt", {
publicUser: user.publicId,
source:
})
connectedAircraft?.Station.bosCallsignShort || connectedDispatcher
? "Leitstelle"
: user.publicId,
});
});
};

View File

@@ -132,5 +132,14 @@ const handlePTT = (data: PTTData) => {
}
};
const handleOtherPTT = (data: PTTData) => {
console.log("Other PTT", data);
useAudioStore.setState({
source: data.source,
});
};
pilotSocket.on("ptt", handlePTT);
pilotSocket.on("other-ptt", handleOtherPTT);
dispatchSocket.on("ptt", handlePTT);
dispatchSocket.on("other-ptt", handleOtherPTT);

Binary file not shown.