Skip to content

Commit f22e4c5

Browse files
authored
Merge branch 'main' into main
2 parents 6bd7852 + 94300ba commit f22e4c5

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

apps/server/src/terrain/processing/terrainworker.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { projectWgs84 } from 'apps/server/src/terrain/processing/gpu/helper';
3838
const DisplayScreenPixelHeightWithoutVerticalDisplay = 768;
3939
const DisplayScreenPixelHeightWithVerticalDisplay = 1024;
4040

41+
const SimBridgeClientDataTimeout = 2 * 60 * 1_000; // ms, equals two minutes
42+
4143
class TerrainWorker {
4244
private initialized: boolean = false;
4345

@@ -54,6 +56,7 @@ class TerrainWorker {
5456
private currentTrackChangesSignificantlyAtDistance: { [side: string]: number } = { L: -1, R: -1 };
5557

5658
private simBridgeClientUsed = false;
59+
public simBridgeClientTimeout: NodeJS.Timeout = null;
5760

5861
private gpu: GPU = null;
5962

@@ -111,6 +114,13 @@ class TerrainWorker {
111114
this.simBridgeClientUsed = true;
112115
}
113116

117+
public disableSimBridgeClientData(): void {
118+
if (this.simBridgeClientUsed) {
119+
this.logging.info('SimBridge client data stopped (due to timeout), resuming SimConnect aircraftStatusUpdate.');
120+
}
121+
this.simBridgeClientUsed = false;
122+
}
123+
114124
private onPositionUpdate(data: PositionData): void {
115125
if (this.initialized === false) return;
116126

@@ -630,6 +640,17 @@ parentPort.on('message', (data: MainToWorkerThreadMessage) => {
630640
} else if (data.type === MainToWorkerThreadMessageTypes.AircraftStatusData) {
631641
terrainWorker.enableSimBridgeClientData();
632642
terrainWorker.onAircraftStatusUpdate(data.content);
643+
644+
// Re-start timeout for disabling the SimBridge client data after two minutes of inactivity
645+
if (terrainWorker.simBridgeClientTimeout !== null) {
646+
clearTimeout(terrainWorker.simBridgeClientTimeout);
647+
terrainWorker.simBridgeClientTimeout = null;
648+
}
649+
650+
terrainWorker.simBridgeClientTimeout = setTimeout(
651+
() => terrainWorker.disableSimBridgeClientData(),
652+
SimBridgeClientDataTimeout,
653+
);
633654
} else if (data.type === MainToWorkerThreadMessageTypes.VerticalDisplayPath) {
634655
terrainWorker.onVerticalPathDataUpdate(data.content);
635656
}

doExe.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const build = exe({
55
entry: './dist/main.js',
66
out: './build/fbw-simbridge.exe',
77
pkg: ['-C', 'GZip', '-c', './package.json'], // Specify extra pkg arguments
8-
version: '0.6.3',
8+
version: '0.7.0',
99
target: 'node18-win-x64',
1010
icon: './apps/server/src/assets/images/tail.ico',
1111
properties: {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fbw-simbridge",
3-
"version": "0.6.3",
3+
"version": "0.7.0",
44
"description": "The simbridge server for FBW addons for various tasks the addons themselves can't achieve",
55
"author": "",
66
"private": false,

0 commit comments

Comments
 (0)