added last talking info to Audio Pannel
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user