mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 09:39:58 +00:00
Add option to enable/disable the backup bridge daemon connection
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
import logger from "./logger";
|
||||
import options from "./options";
|
||||
|
||||
|
||||
const WEBSOCKET_DAEMON_URL = "ws://localhost:9556";
|
||||
|
||||
@@ -96,7 +98,19 @@ function connectNative (application: string) {
|
||||
};
|
||||
|
||||
|
||||
port.onDisconnect.addListener(() => {
|
||||
port.onDisconnect.addListener(async () => {
|
||||
if (!(await options.get("bridgeBackupEnabled"))) {
|
||||
portObject.error = {
|
||||
message: ""
|
||||
};
|
||||
|
||||
for (const listener of onDisconnectListeners) {
|
||||
listener(portObject);
|
||||
}
|
||||
|
||||
throw logger.error("Bridge connection failed and backup not enabled.");
|
||||
}
|
||||
|
||||
if (port.error && !isNativeHostStatusKnown) {
|
||||
isNativeHostStatusKnown = true;
|
||||
|
||||
@@ -152,7 +166,11 @@ async function sendNativeMessage (
|
||||
|
||||
try {
|
||||
return await browser.runtime.sendNativeMessage(application, message);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
if (!(await options.get("bridgeBackupEnabled"))) {
|
||||
throw logger.error("Bridge connection failed and backup not enabled.");
|
||||
}
|
||||
|
||||
return await new Promise((resolve, reject) => {
|
||||
const ws = new WebSocket(WEBSOCKET_DAEMON_URL);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ const storageArea = new TypedStorageArea<{
|
||||
|
||||
export interface Options {
|
||||
bridgeApplicationName: string;
|
||||
bridgeBackupEnabled: boolean;
|
||||
mediaEnabled: boolean;
|
||||
mediaOverlayEnabled: boolean;
|
||||
mediaSyncElement: boolean;
|
||||
|
||||
Reference in New Issue
Block a user