diff --git a/src/GameOptions/ui/RemoteAPIPage.tsx b/src/GameOptions/ui/RemoteAPIPage.tsx index de7ff8f40..b90c006a4 100644 --- a/src/GameOptions/ui/RemoteAPIPage.tsx +++ b/src/GameOptions/ui/RemoteAPIPage.tsx @@ -4,6 +4,7 @@ import { GameOptionsPage } from "./GameOptionsPage"; import { isValidConnectionHostname, isValidConnectionPort, Settings } from "../../Settings/Settings"; import { ConnectionBauble } from "./ConnectionBauble"; import { isRemoteFileApiConnectionLive, newRemoteFileApiConnection } from "../../RemoteFileAPI/RemoteFileAPI"; +import { OptionSwitch } from "../../ui/React/OptionSwitch"; export const RemoteAPIPage = (): React.ReactElement => { const [remoteFileApiHostname, setRemoteFileApiHostname] = useState(Settings.RemoteFileApiAddress); @@ -106,6 +107,12 @@ export const RemoteAPIPage = (): React.ReactElement => { {portError && {portError}} + (Settings.UseWssForRemoteFileApi = newValue)} + text="Use wss" + tooltip={<>Use wss instead of ws when connecting to RFA clients.} + /> diff --git a/src/RemoteFileAPI/Remote.ts b/src/RemoteFileAPI/Remote.ts index b3f7d6b7e..e94a74c38 100644 --- a/src/RemoteFileAPI/Remote.ts +++ b/src/RemoteFileAPI/Remote.ts @@ -2,6 +2,7 @@ import { RFAMessage } from "./MessageDefinitions"; import { RFARequestHandler } from "./MessageHandlers"; import { SnackbarEvents } from "../ui/React/Snackbar"; import { ToastVariant } from "@enums"; +import { Settings } from "../Settings/Settings"; function showErrorMessage(address: string, detail: string) { SnackbarEvents.emit(`Error with websocket ${address}, details: ${detail}`, ToastVariant.ERROR, 5000); @@ -9,7 +10,6 @@ function showErrorMessage(address: string, detail: string) { export class Remote { connection?: WebSocket; - static protocol = "ws"; ipaddr: string; port: number; @@ -23,7 +23,7 @@ export class Remote { } public startConnection(): void { - const address = Remote.protocol + "://" + this.ipaddr + ":" + this.port; + const address = (Settings.UseWssForRemoteFileApi ? "wss" : "ws") + "://" + this.ipaddr + ":" + this.port; try { this.connection = new WebSocket(address); } catch (error) { diff --git a/src/Settings/Settings.ts b/src/Settings/Settings.ts index 655f55311..56ab21329 100644 --- a/src/Settings/Settings.ts +++ b/src/Settings/Settings.ts @@ -113,6 +113,8 @@ export const Settings = { RemoteFileApiAddress: "localhost", /** Port the Remote File API client will try to connect to. 0 to disable. */ RemoteFileApiPort: 0, + /** Use wss instead of ws when connecting to RFA clients */ + UseWssForRemoteFileApi: false, /** Whether to save the game when the player saves any file. */ SaveGameOnFileSave: true, /** Whether to hide the confirmation dialog for augmentation purchases. */ @@ -179,7 +181,7 @@ export const Settings = { hideTrailingDecimalZeros: false, /** Whether to hide thousands separators. */ hideThousandsSeparator: false, - /** Whether to use engineering notation instead of scientific for exponentials. */ + /** Whether to use engineering notation instead of scientific for exponential form. */ useEngineeringNotation: false, /** Whether to disable suffixes and always use exponential form (scientific or engineering). */ disableSuffixes: false,