added last talking info to Audio Pannel
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { getPublicUser, prisma } from "@repo/db";
|
||||
import { channel } from "diagnostics_channel";
|
||||
import { Server, Socket } from "socket.io";
|
||||
|
||||
export const handleConnectPilot =
|
||||
@@ -14,6 +15,11 @@ export const handleConnectPilot =
|
||||
const user = socket.data.user; // User ID aus dem JWT-Token
|
||||
const userId = socket.data.user.id; // User ID aus dem JWT-Token
|
||||
|
||||
const Station = await prisma.station.findFirst({
|
||||
where: {
|
||||
id: parseInt(stationId),
|
||||
},
|
||||
});
|
||||
console.log("Pilot connected:", userId);
|
||||
|
||||
if (!user) return Error("User not found");
|
||||
@@ -84,10 +90,19 @@ export const handleConnectPilot =
|
||||
);
|
||||
|
||||
// Add a listener for station-specific events
|
||||
socket.on(`station:${stationId}:event`, async (data) => {
|
||||
console.log(`Received event for station ${stationId}:`, data);
|
||||
// Handle station-specific logic here
|
||||
io.to(`station:${stationId}`).emit("station-event-update", data);
|
||||
socket.on("ptt", async ({ shouldTransmit, channel }) => {
|
||||
if (shouldTransmit) {
|
||||
io.to("dispatchers").emit("other-ptt", {
|
||||
publicUser: getPublicUser(user),
|
||||
channel,
|
||||
source: Station?.bosCallsignShort,
|
||||
});
|
||||
io.to("piots").emit("other-ptt", {
|
||||
publicUser: getPublicUser(user),
|
||||
channel,
|
||||
source: Station?.bosCallsignShort,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("disconnect", async () => {
|
||||
|
||||
Reference in New Issue
Block a user