MRT: Rufgruppenauswahl, Herunterfahren, Hilfe
This commit is contained in:
@@ -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<TalkState>((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<TalkState>((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<TalkState>((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<TalkState>((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<TalkState>((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<TalkState>((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 });
|
||||
|
||||
@@ -48,7 +48,7 @@ export const useDispatchConnectionStore = create<ConnectionStore>((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,
|
||||
|
||||
@@ -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<MrtStore>((set) => ({
|
||||
page: "off",
|
||||
nightMode: false,
|
||||
stringifiedData: {},
|
||||
stringifiedData: {
|
||||
groupSelectionGroupId: "2201",
|
||||
},
|
||||
setNightMode: (nightMode) => set({ nightMode }),
|
||||
setStringifiedData: (data) =>
|
||||
set((state) => ({
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user