Skip to content

Commit

Permalink
fix: auto reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlauer-Hax committed Oct 21, 2023
1 parent 3493b73 commit f42d1a9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pages/hosting/loading.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HmRequest, LoginRequest, MessageType, PublishResponse, SubscribeRequest, TriggerRequest } from "https://deno.land/x/hmsys_connector@0.9.0/mod.ts";
import { API } from "shared";
import { Deferred, deferred } from "std/async/deferred.ts";
import { delay } from "std/async/delay.ts";
import { State, asPointer, lazyInit } from "webgen/mod.ts";
import { Server, ServerDetails, SidecarRequest, SidecarResponse } from "../../spec/music.ts";
import { activeUser, tokens } from "../_legacy/helper.ts";
Expand Down Expand Up @@ -166,8 +167,10 @@ export async function startSidecarConnection(id: string) {
isSidecarConnect.setValue(true);
};

ws.onclose = () => {
ws.onclose = async () => {
if (!activeSideCar) return;
await delay(500);
activeSideCar = undefined;
isSidecarConnect.setValue(false);
clearInterval(watcher);
startSidecarConnection(id);
Expand Down

0 comments on commit f42d1a9

Please sign in to comment.