mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
MISC: Allow using wss for RFA (#1942)
This commit is contained in:
@@ -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 && <Typography color={Settings.theme.error}>{portError}</Typography>}
|
||||
</div>
|
||||
</Tooltip>
|
||||
<OptionSwitch
|
||||
checked={Settings.UseWssForRemoteFileApi}
|
||||
onChange={(newValue) => (Settings.UseWssForRemoteFileApi = newValue)}
|
||||
text="Use wss"
|
||||
tooltip={<>Use wss instead of ws when connecting to RFA clients.</>}
|
||||
/>
|
||||
<Button disabled={!isValidHostname || !isValidPort} onClick={newRemoteFileApiConnection}>
|
||||
Connect
|
||||
</Button>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user