-
MRT & DME
+
{
const {
+ selectedRoom,
speakingParticipants,
resetSpeakingParticipants,
isTalking,
@@ -37,8 +38,8 @@ export const Audio = () => {
room,
message,
removeMessage,
+ setSelectedRoom,
} = useAudioStore();
- const [selectedRoom, setSelectedRoom] = useState("VAR_LST_RD_01");
useSounds({
isReceiving: speakingParticipants.length > 0,
@@ -48,7 +49,7 @@ export const Audio = () => {
});
const { selectedStation, status: pilotState } = usePilotConnectionStore((state) => state);
- const { selectedZone, status: dispatcherState } = useDispatchConnectionStore((state) => state);
+ const { status: dispatcherState } = useDispatchConnectionStore((state) => state);
const session = useSession();
const [isReceivingBlick, setIsReceivingBlick] = useState(false);
const [recentSpeakers, setRecentSpeakers] = useState([]);
@@ -93,7 +94,7 @@ export const Audio = () => {
const canStopOtherSpeakers = dispatcherState === "connected";
const role =
- (dispatcherState === "connected" && selectedZone) ||
+ (dispatcherState === "connected" && "VAR LST") ||
(pilotState == "connected" && selectedStation?.bosCallsignShort) ||
session.data?.user?.publicId;
@@ -190,9 +191,9 @@ export const Audio = () => {
className="btn btn-sm btn-ghost relative flex items-center justify-start gap-2 text-left"
onClick={() => {
if (!role) return;
- if (selectedRoom === r.name) return;
- setSelectedRoom(r.name);
- connect(r.name, role);
+ if (selectedRoom?.name === r.name) return;
+ setSelectedRoom(r);
+ connect(r, role);
}}
>
{room?.name === r.name && (
diff --git a/apps/dispatch/app/_data/livekitRooms.ts b/apps/dispatch/app/_data/livekitRooms.ts
index 0ed6c0b5..f98a61aa 100644
--- a/apps/dispatch/app/_data/livekitRooms.ts
+++ b/apps/dispatch/app/_data/livekitRooms.ts
@@ -1,7 +1,7 @@
export const ROOMS = [
- { name: "VAR_LST_RD_01", id: 2201 },
- { name: "VAR_LST_RD_02", id: 2202 },
- { name: "VAR_LST_RD_03", id: 2203 },
- { name: "VAR_LST_RD_04", id: 2204 },
- { name: "VAR_LST_RD_05", id: 2205 },
+ { name: "VAR_LST_RD_01", id: "2201" },
+ { name: "VAR_LST_RD_02", id: "2202" },
+ { name: "VAR_LST_RD_03", id: "2203" },
+ { name: "VAR_LST_RD_04", id: "2204" },
+ { name: "VAR_LST_RD_05", id: "2205" },
];
diff --git a/apps/dispatch/app/_store/audioStore.ts b/apps/dispatch/app/_store/audioStore.ts
index 7ce25c64..714264b2 100644
--- a/apps/dispatch/app/_store/audioStore.ts
+++ b/apps/dispatch/app/_store/audioStore.ts
@@ -21,12 +21,15 @@ import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
import { changeDispatcherAPI } from "_querys/dispatcher";
import { getRadioStream } from "_helpers/radioEffect";
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
+import { ROOMS } from "_data/livekitRooms";
let interval: NodeJS.Timeout;
+const connectedSound = new Audio("/sounds/403.wav");
+
type TalkState = {
addSpeakingParticipant: (participant: Participant) => void;
- connect: (roomName: string, role: string) => void;
+ connect: (room: (typeof ROOMS)[number] | undefined, role: string) => void;
connectionQuality: ConnectionQuality;
disconnect: () => void;
isTalking: boolean;
@@ -44,6 +47,8 @@ type TalkState = {
radioVolume: number;
dmeVolume: number;
};
+ selectedRoom?: (typeof ROOMS)[number];
+ setSelectedRoom: (room: (typeof ROOMS)[number]) => void;
speakingParticipants: Participant[];
state: "connecting" | "connected" | "disconnected" | "error";
toggleTalking: () => void;
@@ -72,6 +77,10 @@ export const useAudioStore = create((set, get) => ({
remoteParticipants: 0,
connectionQuality: ConnectionQuality.Unknown,
room: null,
+ selectedRoom: ROOMS[0],
+ setSelectedRoom: (room) => {
+ set({ selectedRoom: room });
+ },
resetSpeakingParticipants: (source: string) => {
set({
speakingParticipants: [],
@@ -117,11 +126,11 @@ export const useAudioStore = create((set, get) => ({
(oldSettings.micDeviceId !== newSettings.micDeviceId ||
oldSettings.micVolume !== newSettings.micVolume)
) {
- const { room, disconnect, connect } = get();
+ const { room, disconnect, connect, selectedRoom } = get();
const role = room?.localParticipant.attributes.role;
- if (room?.name || role) {
+ if (selectedRoom || role) {
disconnect();
- connect(room?.name || "", role || "user");
+ connect(selectedRoom, role || "user");
}
}
},
@@ -160,7 +169,7 @@ export const useAudioStore = create((set, get) => ({
set((state) => ({ isTalking: !state.isTalking, transmitBlocked: false }));
},
- connect: async (roomName, role) => {
+ connect: async (_room, role) => {
set({ state: "connecting" });
try {
@@ -172,10 +181,12 @@ export const useAudioStore = create((set, get) => ({
connectedRoom.removeAllListeners();
}
+ const { selectedRoom } = get();
+
const url = process.env.NEXT_PUBLIC_LIVEKIT_URL;
if (!url) return console.error("NEXT_PUBLIC_LIVEKIT_URL not set");
- const token = await getToken(roomName);
+ const token = await getToken(_room?.name || selectedRoom?.name || "VAR_LST_RD_01");
if (!token) throw new Error("Fehlende Berechtigung");
const room = new Room({});
await room.prepareConnection(url, token);
@@ -186,7 +197,7 @@ export const useAudioStore = create((set, get) => ({
if (dispatchState.status === "connected" && dispatchState.connectedDispatcher?.id) {
changeDispatcherAPI(dispatchState.connectedDispatcher?.id, {
- zone: roomName,
+ zone: _room?.name || selectedRoom?.name || "VAR_LST_RD_01",
ghostMode: dispatchState.ghostMode,
});
}
@@ -208,7 +219,7 @@ export const useAudioStore = create((set, get) => ({
source: Track.Source.Microphone,
});
await publishedTrack.mute();
-
+ connectedSound.play().catch((e) => console.error("Fehler beim Abspielen des Sounds", e));
set({ localRadioTrack: publishedTrack });
set({ state: "connected", room, isTalking: false, message: null });
diff --git a/apps/dispatch/app/_store/dispatch/connectionStore.ts b/apps/dispatch/app/_store/dispatch/connectionStore.ts
index 2e5bb4c1..9663e473 100644
--- a/apps/dispatch/app/_store/dispatch/connectionStore.ts
+++ b/apps/dispatch/app/_store/dispatch/connectionStore.ts
@@ -48,7 +48,7 @@ export const useDispatchConnectionStore = create((set) => ({
dispatchSocket.on("connect", () => {
const { logoffTime, selectedZone, ghostMode } = useDispatchConnectionStore.getState();
- useAudioStore.getState().connect("VAR_LST_RD_01", selectedZone || "Leitstelle");
+ useAudioStore.getState().connect(undefined, selectedZone || "Leitstelle");
dispatchSocket.emit("connect-dispatch", {
logoffTime,
selectedZone,
diff --git a/apps/dispatch/app/_store/pilot/MrtStore.ts b/apps/dispatch/app/_store/pilot/MrtStore.ts
index a2a4525f..f8432402 100644
--- a/apps/dispatch/app/_store/pilot/MrtStore.ts
+++ b/apps/dispatch/app/_store/pilot/MrtStore.ts
@@ -19,6 +19,10 @@ interface SetSdsReceivedPopupParams {
popup: "sds-received";
}
+interface SetGroupSelectionPopupParams {
+ popup: "group-selection";
+}
+
interface SetStatusSentPopupParams {
popup: "status-sent";
}
@@ -40,6 +44,7 @@ export type SetPageParams =
export type SetPopupParams =
| SetStatusSentPopupParams
| SetSdsSentPopupParams
+ | SetGroupSelectionPopupParams
| SetSdsReceivedPopupParams
| SetLoginPopupParams;
@@ -47,6 +52,7 @@ interface StringifiedData {
sdsText?: string;
sentSdsText?: string;
+ groupSelectionGroupId?: string;
callTextHeader?: string;
}
@@ -69,7 +75,9 @@ interface MrtStore {
export const useMrtStore = create((set) => ({
page: "off",
nightMode: false,
- stringifiedData: {},
+ stringifiedData: {
+ groupSelectionGroupId: "2201",
+ },
setNightMode: (nightMode) => set({ nightMode }),
setStringifiedData: (data) =>
set((state) => ({
diff --git a/apps/dispatch/app/_store/pilot/connectionStore.ts b/apps/dispatch/app/_store/pilot/connectionStore.ts
index 15e3109d..1ca44645 100644
--- a/apps/dispatch/app/_store/pilot/connectionStore.ts
+++ b/apps/dispatch/app/_store/pilot/connectionStore.ts
@@ -86,7 +86,7 @@ pilotSocket.on("connect", () => {
usePilotConnectionStore.setState({ status: "connected", message: "" });
const { logoffTime, selectedStation, debug } = usePilotConnectionStore.getState();
dispatchSocket.disconnect();
- useAudioStore.getState().connect("VAR_LST_RD_01", selectedStation?.bosCallsignShort || "pilot");
+ useAudioStore.getState().connect(undefined, selectedStation?.bosCallsignShort || "pilot");
pilotSocket.emit("connect-pilot", {
logoffTime,