added MEasurement-tool, added Dispatch-name auto change
This commit is contained in:
@@ -9,6 +9,8 @@ import { ConnectionQuality, Participant, Room, RoomEvent, RpcInvocationData } fr
|
||||
import { pilotSocket } from "pilot/socket";
|
||||
import { create } from "zustand";
|
||||
import axios from "axios";
|
||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
import { changeDispatcherAPI } from "_querys/dispatcher";
|
||||
|
||||
let interval: NodeJS.Timeout;
|
||||
|
||||
@@ -95,7 +97,7 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
},
|
||||
connect: async (roomName, role) => {
|
||||
set({ state: "connecting" });
|
||||
console.log("Connecting to room: ", roomName);
|
||||
|
||||
try {
|
||||
// Clean old room
|
||||
const connectedRoom = get().room;
|
||||
@@ -114,7 +116,15 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
await room.prepareConnection(url, token);
|
||||
room
|
||||
// Connection events
|
||||
.on(RoomEvent.Connected, () => {
|
||||
.on(RoomEvent.Connected, async () => {
|
||||
const dispatchState = useDispatchConnectionStore.getState();
|
||||
|
||||
if (dispatchState.status === "connected" && dispatchState.connectedDispatcher?.id) {
|
||||
changeDispatcherAPI(dispatchState.connectedDispatcher?.id, {
|
||||
zone: roomName,
|
||||
});
|
||||
}
|
||||
|
||||
set({ state: "connected", room, message: null });
|
||||
})
|
||||
.on(RoomEvent.Disconnected, () => {
|
||||
|
||||
Reference in New Issue
Block a user