mirror of
https://github.com/DerTyp7/teamspeak-obs-overlay.git
synced 2025-10-29 12:52:09 +01:00
[fix] bug while reconnecting server
This commit is contained in:
@@ -5,9 +5,7 @@ import App from "./App.tsx";
|
|||||||
import "@styles/index.scss";
|
import "@styles/index.scss";
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||||
<React.StrictMode>
|
<BrowserRouter>
|
||||||
<BrowserRouter>
|
<App />
|
||||||
<App />
|
</BrowserRouter>
|
||||||
</BrowserRouter>
|
|
||||||
</React.StrictMode>
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class TS5Connection {
|
|||||||
setConnections: React.Dispatch<React.SetStateAction<IConnection[]>>,
|
setConnections: React.Dispatch<React.SetStateAction<IConnection[]>>,
|
||||||
setChannels: React.Dispatch<React.SetStateAction<IChannel[]>>,
|
setChannels: React.Dispatch<React.SetStateAction<IChannel[]>>,
|
||||||
setClients: React.Dispatch<React.SetStateAction<IClient[]>>,
|
setClients: React.Dispatch<React.SetStateAction<IClient[]>>,
|
||||||
setActiveConnectionId: React.Dispatch<React.SetStateAction<number>>,
|
setActiveConnectionStateId: React.Dispatch<React.SetStateAction<number>>,
|
||||||
) {
|
) {
|
||||||
// Create websocket connection to TS5 client
|
// Create websocket connection to TS5 client
|
||||||
this.remoteAppPort = remoteAppPort;
|
this.remoteAppPort = remoteAppPort;
|
||||||
@@ -26,7 +26,7 @@ export class TS5Connection {
|
|||||||
|
|
||||||
// Create dataHandler and messageHandler
|
// Create dataHandler and messageHandler
|
||||||
this.dataHandler = new TS5DataHandler(setConnections, setChannels, setClients);
|
this.dataHandler = new TS5DataHandler(setConnections, setChannels, setClients);
|
||||||
this.messageHandler = new TS5MessageHandler(this.ws, this.dataHandler, setActiveConnectionId);
|
this.messageHandler = new TS5MessageHandler(this.ws, this.dataHandler, setActiveConnectionStateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnect() {
|
reconnect() {
|
||||||
@@ -328,12 +328,18 @@ class TS5MessageHandler {
|
|||||||
ws: WebSocket;
|
ws: WebSocket;
|
||||||
dataHandler: TS5DataHandler;
|
dataHandler: TS5DataHandler;
|
||||||
|
|
||||||
setActiveConnectionId: React.Dispatch<React.SetStateAction<number>>;
|
setActiveConnectionStateId: React.Dispatch<React.SetStateAction<number>>;
|
||||||
|
activeConnectionId = 0;
|
||||||
|
|
||||||
constructor(ws: WebSocket, dataHandler: TS5DataHandler, setActiveConnectionId: React.Dispatch<React.SetStateAction<number>>) {
|
constructor(ws: WebSocket, dataHandler: TS5DataHandler, setActiveConnectionStateId: React.Dispatch<React.SetStateAction<number>>) {
|
||||||
this.ws = ws;
|
this.ws = ws;
|
||||||
this.dataHandler = dataHandler;
|
this.dataHandler = dataHandler;
|
||||||
this.setActiveConnectionId = setActiveConnectionId;
|
this.setActiveConnectionStateId = setActiveConnectionStateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
setActiveConnection(connectionId: number) {
|
||||||
|
this.activeConnectionId = connectionId;
|
||||||
|
this.setActiveConnectionStateId(connectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseChannelInfos(channelInfos: IChannelInfos, connection: IConnection) {
|
parseChannelInfos(channelInfos: IChannelInfos, connection: IConnection) {
|
||||||
@@ -476,8 +482,10 @@ class TS5MessageHandler {
|
|||||||
handleClientSelfPropertyUpdatedMessage(data: IClientSelfPropertyUpdatedMessage) {
|
handleClientSelfPropertyUpdatedMessage(data: IClientSelfPropertyUpdatedMessage) {
|
||||||
console.log("handleClientSelfPropertyUpdated", data);
|
console.log("handleClientSelfPropertyUpdated", data);
|
||||||
|
|
||||||
if (data.payload.flag == "inputHardware") { // sadly thats the only way to detect if a server is active or not
|
const connection: IConnection | undefined = this.dataHandler.getConnectionById(this.activeConnectionId);
|
||||||
this.setActiveConnectionId(data.payload.connectionId);
|
|
||||||
|
if (data.payload.flag == "inputHardware" || connection == undefined) { // sadly thats the only way to detect if a server is active or not
|
||||||
|
this.setActiveConnection(data.payload.connectionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user