From 8ceb32c958f670bcd36884a65a59e2f958b310a5 Mon Sep 17 00:00:00 2001 From: Christian-Holbrook <118202694+Christian-Holbrook@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:37:28 -0800 Subject: [PATCH] Make the connection port for SceneGraphDebugCommandController configurable (#177) * Make the connection port for SceneGraphDebugCommandController configurable * Update src/SceneGraphDebugCommandController.ts Co-authored-by: Bronley Plumb * Update src/SceneGraphDebugCommandController.ts * Add description to sceneGraphDebugCommandsPort * Update src/LaunchConfiguration.ts --------- Co-authored-by: Christian Holbrook Co-authored-by: Bronley Plumb --- src/LaunchConfiguration.ts | 6 ++++++ src/RendezvousTracker.ts | 2 +- src/SceneGraphDebugCommandController.ts | 5 +++-- src/debugSession/BrightScriptDebugSession.ts | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/LaunchConfiguration.ts b/src/LaunchConfiguration.ts index fe5abfb4..fd5e2c5a 100644 --- a/src/LaunchConfiguration.ts +++ b/src/LaunchConfiguration.ts @@ -266,6 +266,12 @@ export interface LaunchConfiguration extends DebugProtocol.LaunchRequestArgument * @default false */ deleteDevChannelBeforeInstall: boolean; + + /** + * sceneGraphDebugCommandsPort + * The port that should be used to send SceneGraph debug commands. Defaults to 8080. + */ + sceneGraphDebugCommandsPort: number; } export interface ComponentLibraryConfiguration { diff --git a/src/RendezvousTracker.ts b/src/RendezvousTracker.ts index 1cf32322..e60a206c 100644 --- a/src/RendezvousTracker.ts +++ b/src/RendezvousTracker.ts @@ -140,7 +140,7 @@ export class RendezvousTracker { * Run a SceneGraph logendezvous 8080 command and get the text output */ private async runSGLogrendezvousCommand(command: 'status' | 'on' | 'off'): Promise { - let sgDebugCommandController = new SceneGraphDebugCommandController(this.launchConfiguration.host); + let sgDebugCommandController = new SceneGraphDebugCommandController(this.launchConfiguration.host, this.launchConfiguration.sceneGraphDebugCommandsPort); try { this.logger.info(`port 8080 command: logrendezvous ${command}`); return (await sgDebugCommandController.logrendezvous(command)).result.rawResponse; diff --git a/src/SceneGraphDebugCommandController.ts b/src/SceneGraphDebugCommandController.ts index c3c08547..c1b77141 100644 --- a/src/SceneGraphDebugCommandController.ts +++ b/src/SceneGraphDebugCommandController.ts @@ -4,7 +4,8 @@ import { logger } from './logging'; const Telnet = require('telnet-client'); export class SceneGraphDebugCommandController { - constructor(public host: string) { + constructor(public host: string, port?: number) { + this.port = port ?? 8080; } private connection: typeof Telnet; @@ -13,7 +14,7 @@ export class SceneGraphDebugCommandController { private echoLines = 0; public timeout = 5000; public execTimeout = 2000; - private port = 8080; + private port; private maxBufferLength = 5242880; private logger = logger.createLogger(`[${SceneGraphDebugCommandController.name}]`); diff --git a/src/debugSession/BrightScriptDebugSession.ts b/src/debugSession/BrightScriptDebugSession.ts index baad1d4c..761aa6ba 100644 --- a/src/debugSession/BrightScriptDebugSession.ts +++ b/src/debugSession/BrightScriptDebugSession.ts @@ -533,7 +533,7 @@ export class BrightScriptDebugSession extends BaseDebugSession { private async runAutomaticSceneGraphCommands(commands: string[]) { if (commands) { - let connection = new SceneGraphDebugCommandController(this.launchConfiguration.host); + let connection = new SceneGraphDebugCommandController(this.launchConfiguration.host, this.launchConfiguration.sceneGraphDebugCommandsPort); try { await connection.connect();