Nachalarmieren select
Alarmieren aus Einsatz erstellen Maske Map-Tiles SDS sound: Status J SDS Nachricht: public-User Audio: Es kann nur ein Nutzer gleichzeitig Funken Select in Report und Chat: default value -> OnChange
This commit is contained in:
@@ -18,6 +18,7 @@ type TalkState = {
|
||||
micDeviceId: string | null;
|
||||
micVolume: number;
|
||||
isTalking: boolean;
|
||||
transmitBlocked: boolean;
|
||||
removeMessage: () => void;
|
||||
state: "connecting" | "connected" | "disconnected" | "error";
|
||||
message: string | null;
|
||||
@@ -40,12 +41,12 @@ const getToken = async (roomName: string) => {
|
||||
|
||||
export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
isTalking: false,
|
||||
transmitBlocked: false,
|
||||
message: null,
|
||||
micDeviceId: null,
|
||||
speakingParticipants: [],
|
||||
micVolume: 1,
|
||||
state: "disconnected",
|
||||
source: "",
|
||||
remoteParticipants: 0,
|
||||
connectionQuality: ConnectionQuality.Unknown,
|
||||
room: null,
|
||||
@@ -61,39 +62,38 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
set({ message: null });
|
||||
},
|
||||
removeSpeakingParticipant: (participant) => {
|
||||
const newSpeaktingParticipants = get().speakingParticipants.filter(
|
||||
(p) => !(p.identity === participant.identity),
|
||||
);
|
||||
set((state) => ({
|
||||
speakingParticipants: state.speakingParticipants.filter(
|
||||
(p) => !(p.identity === participant.identity),
|
||||
),
|
||||
speakingParticipants: newSpeaktingParticipants,
|
||||
}));
|
||||
if (newSpeaktingParticipants.length === 0 && get().transmitBlocked) {
|
||||
get().room?.localParticipant.setMicrophoneEnabled(true);
|
||||
set({ transmitBlocked: false, message: null, isTalking: true });
|
||||
}
|
||||
},
|
||||
setMic: (micDeviceId, micVolume) => {
|
||||
set({ micDeviceId, micVolume });
|
||||
},
|
||||
toggleTalking: () => {
|
||||
const { room, isTalking, micDeviceId, micVolume } = get();
|
||||
const { room, isTalking, micDeviceId, micVolume, speakingParticipants } = get();
|
||||
if (!room) return;
|
||||
|
||||
if (speakingParticipants.length > 0 && !isTalking) {
|
||||
// Wenn andere sprechen, nicht reden
|
||||
set({
|
||||
message: "Rufgruppe besetzt",
|
||||
transmitBlocked: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
// Todo: use micVolume
|
||||
room.localParticipant.setMicrophoneEnabled(!isTalking, {
|
||||
deviceId: micDeviceId ?? undefined,
|
||||
});
|
||||
|
||||
if (!isTalking) {
|
||||
// If old status was not talking, we need to emit the PTT event
|
||||
if (pilotSocket.connected) {
|
||||
pilotSocket.emit("ptt", {
|
||||
shouldTransmit: true,
|
||||
channel: room.name,
|
||||
});
|
||||
}
|
||||
if (dispatchSocket.connected)
|
||||
dispatchSocket.emit("ptt", {
|
||||
shouldTransmit: true,
|
||||
channel: room.name,
|
||||
});
|
||||
}
|
||||
|
||||
set((state) => ({ isTalking: !state.isTalking }));
|
||||
set((state) => ({ isTalking: !state.isTalking, transmitBlocked: false }));
|
||||
},
|
||||
connect: async (roomName, role) => {
|
||||
set({ state: "connecting" });
|
||||
@@ -181,11 +181,21 @@ interface PTTData {
|
||||
|
||||
const handlePTT = (data: PTTData) => {
|
||||
const { shouldTransmit, source } = data;
|
||||
const { room } = useAudioStore.getState();
|
||||
const { room, speakingParticipants } = useAudioStore.getState();
|
||||
if (!room) return;
|
||||
|
||||
if (speakingParticipants.length > 0 && shouldTransmit) {
|
||||
// Wenn andere sprechen, nicht reden
|
||||
useAudioStore.setState({
|
||||
message: "Rufgruppe besetzt",
|
||||
transmitBlocked: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
useAudioStore.setState({
|
||||
isTalking: shouldTransmit,
|
||||
transmitBlocked: false,
|
||||
});
|
||||
|
||||
if (shouldTransmit) {
|
||||
|
||||
Reference in New Issue
Block a user