From 1a66fb54c0a9da7d392cb724541bd5ac03c19807 Mon Sep 17 00:00:00 2001 From: Alex Anderson Date: Wed, 12 Oct 2022 19:56:49 -0400 Subject: [PATCH 1/3] Fix some issues with failing websockets --- client/src/components/WelcomeButtons.tsx | 4 ++-- desktop/main/electron.ts | 3 ++- server/src/index.ts | 13 +++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/client/src/components/WelcomeButtons.tsx b/client/src/components/WelcomeButtons.tsx index d5d60d02..fc692564 100644 --- a/client/src/components/WelcomeButtons.tsx +++ b/client/src/components/WelcomeButtons.tsx @@ -69,7 +69,7 @@ export const WelcomeButtons = ({className}: {className?: string}) => { How-to Guides - {process.env.NODE_ENV === "production" && + {/* {process.env.NODE_ENV === "production" && location.protocol !== "https:" && ( { > Use HTTPS - )} + )} */} )} diff --git a/desktop/main/electron.ts b/desktop/main/electron.ts index 02e1d5da..20e6796f 100644 --- a/desktop/main/electron.ts +++ b/desktop/main/electron.ts @@ -13,6 +13,7 @@ import {initWin} from "./helpers/autoUpdate"; let win: BrowserWindow | null = null; app.enableSandbox(); +app.commandLine.appendSwitch("ignore-certificate-errors"); function loadFile(url: string) { dialog.showMessageBox({message: url}); @@ -80,7 +81,7 @@ async function createWindow() { // We add 1 to the port, since we want to connect to the HTTPS server // which is 1 more than the default port - win.loadURL(`https://localhost:${port + 1}`); + win.loadURL(`http://localhost:${port}`); win.on("closed", () => { win = null; }); diff --git a/server/src/index.ts b/server/src/index.ts index 78cd966a..f672bf9f 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -11,7 +11,10 @@ import {FlightDataModel} from "./classes/FlightDataModel"; import {promises as fs, existsSync} from "fs"; import {unzip} from "./utils/unzipFolder"; import {buildHttpsProxy} from "./init/httpsProxy"; -import fastify from "fastify"; +import fastify, {RawServerBase} from "fastify"; +// @ts-expect-error Importing from untyped file +import symbols from "fastify/lib/symbols.js"; + setBasePath(thoriumPath); const isHeadless = !process.env.FORK; @@ -64,11 +67,17 @@ export async function startServer() { Number(process.env.PORT) || (process.env.NODE_ENV === "production" ? 4444 : 3001); const HTTPSPort = PORT + 1; - const proxy = buildHttpsProxy(PORT); try { await app.listen({port: PORT}); + // @ts-expect-error can't index with any + app[symbols.kServerBindings].forEach((server: RawServerBase) => { + server.on("upgrade", (...args: any[]) => { + app.server.emit("upgrade", ...args); + }); + }); if (process.env.NODE_ENV === "production") { + const proxy = buildHttpsProxy(PORT); await proxy.listen({port: HTTPSPort}); } console.info(chalk.greenBright(`Access app at http://localhost:${PORT}`)); From 5a1a5a6fc27e1e57352607af4f640ff9607db2c8 Mon Sep 17 00:00:00 2001 From: Alex Anderson Date: Thu, 1 Dec 2022 19:23:39 -0500 Subject: [PATCH 2/3] A few minor improvements and bug fixes --- client/src/cards/Pilot/index.tsx | 2 +- client/src/components/QuoteOfTheDay.tsx | 9 ++++++++- client/src/components/WelcomeButtons.tsx | 6 +++--- server/src/systems/PassengerMovementSystem.ts | 6 ++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/client/src/cards/Pilot/index.tsx b/client/src/cards/Pilot/index.tsx index 5dc82a67..f64fb4fb 100644 --- a/client/src/cards/Pilot/index.tsx +++ b/client/src/cards/Pilot/index.tsx @@ -58,7 +58,7 @@ export function Pilot({cardLoaded}: CardProps) { -
+
diff --git a/client/src/components/QuoteOfTheDay.tsx b/client/src/components/QuoteOfTheDay.tsx index 39a4958f..b5a29f89 100644 --- a/client/src/components/QuoteOfTheDay.tsx +++ b/client/src/components/QuoteOfTheDay.tsx @@ -208,7 +208,7 @@ const quotes = [ // Steve Jobs "The most powerful person in the world is the storyteller.", // Hey Now - "Imagination calling mirrors for you", + "Imagination calling mirrors for you.", // Albert Einstein "The only reason for time is so that everything doesn't happen at once.", "Reality is merely an illusion, albeit a very persistent one.", @@ -226,6 +226,7 @@ const quotes = [ "We are autumn children, burdened with memories of sun.", "Impudent of you to assume I will meet a mortal end.", "Heaven, are you watching?", + "You're the wind. You're the stars. You are all endless things.", // Larry Elison "Choose your competitors carefully, because you'll become a lot like them.", // William Martin @@ -235,6 +236,12 @@ const quotes = [ // Brene Brown "No one belongs here more than you.", "When we own the story, we can write a brave new ending.", + // Timothy Dexter + "I am the first in the east. I am the first in the west. I am the first of all things.", + // Václav Havel + "Hope is not the conviction that something will turn out well, but the certainty that something is worth doing no matter how it turns out.", + // Pierre Coubertin + "The important thing in life is not the triumph, but the struggle.", ]; const QuoteOfTheDay = () => { diff --git a/client/src/components/WelcomeButtons.tsx b/client/src/components/WelcomeButtons.tsx index fc692564..0560d0d6 100644 --- a/client/src/components/WelcomeButtons.tsx +++ b/client/src/components/WelcomeButtons.tsx @@ -39,7 +39,7 @@ export const WelcomeButtons = ({className}: {className?: string}) => { > Start Flight - + {/* Load a Saved Flight @@ -56,11 +56,11 @@ export const WelcomeButtons = ({className}: {className?: string}) => { > - + */} )} - + {/* */} {client.isHost && ( Configure Plugins diff --git a/server/src/systems/PassengerMovementSystem.ts b/server/src/systems/PassengerMovementSystem.ts index 5ff99d59..ad7e5655 100644 --- a/server/src/systems/PassengerMovementSystem.ts +++ b/server/src/systems/PassengerMovementSystem.ts @@ -7,7 +7,7 @@ export class PassengerMovementSystem extends System { entity.components.passengerMovement && entity.components.position ); } - frequency = 20; + frequency = 5; update(entity: Entity, elapsed: number) { const elapsedRatio = elapsed / (1000 / this.frequency); const {position, passengerMovement} = entity.components; @@ -28,7 +28,9 @@ export class PassengerMovementSystem extends System { ship.components.shipMap.deckNodeMap?.[ passengerMovement.nodePath[passengerMovement.nextNodeIndex] ]; - if (!nextNode) return; + if (!nextNode) { + return; + } const distanceToNext = Math.hypot(x - nextNode?.x, y - nextNode?.y); // Increment to the next node if (distanceToNext <= 0.1 && z === nextNode.deckIndex) { passengerMovement.nextNodeIndex++; From c93cf4e2f71956ee698b314bd479ad8164542a61 Mon Sep 17 00:00:00 2001 From: Alex Anderson Date: Thu, 1 Dec 2022 19:27:39 -0500 Subject: [PATCH 3/3] FIx tests. --- .../__test__/PassengerMovementSystem.test.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/systems/__test__/PassengerMovementSystem.test.ts b/server/src/systems/__test__/PassengerMovementSystem.test.ts index 7a493305..a29f3d95 100644 --- a/server/src/systems/__test__/PassengerMovementSystem.test.ts +++ b/server/src/systems/__test__/PassengerMovementSystem.test.ts @@ -128,8 +128,8 @@ describe("PassengerMovementSystem", () => { PositionComponent { "parentId": 1, "type": "ship", - "x": 0.2941564209736038, - "y": 0.2941564209736038, + "x": 0.4378550077971717, + "y": 0.4378550077971716, "z": 0, } `); @@ -139,8 +139,8 @@ describe("PassengerMovementSystem", () => { PositionComponent { "parentId": 1, "type": "ship", - "x": 0.9525462151064351, - "y": 0.9525462151064351, + "x": 1.0991613293113442, + "y": 0.9455613293113442, "z": 0, } `); @@ -205,7 +205,7 @@ describe("PassengerMovementSystem", () => { "type": "ship", "x": 2, "y": 1, - "z": 0.041600000000000005, + "z": 0.0728, } `); expect(passenger.components.passengerMovement?.nextNodeIndex).toBe(1); @@ -214,8 +214,8 @@ describe("PassengerMovementSystem", () => { PositionComponent { "parentId": 3, "type": "ship", - "x": 2, - "y": 1, + "x": 1.5621449922028285, + "y": 0.5621449922028283, "z": 1, } `); @@ -224,8 +224,8 @@ describe("PassengerMovementSystem", () => { PositionComponent { "parentId": 3, "type": "ship", - "x": 1.2219398082404278, - "y": 0.22193980824042775, + "x": 1.1480653998204364, + "y": 0.14806539982043648, "z": 1, } `);