File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed
Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const { Subject } = require('await-notify');
2121interface LaunchRequestArguments extends DebugProtocol . LaunchRequestArguments {
2222 stopOnEntry ?: boolean ;
2323 trace ?: boolean ;
24+ port ?: number ;
2425}
2526
2627interface ASBreakpoint
@@ -41,6 +42,8 @@ export class ASDebugSession extends LoggingDebugSession
4142
4243 private _configurationDone = new Subject ( ) ;
4344
45+ port = 27099 ;
46+
4447 /**
4548 * Creates a new debug adapter that is used for one debug session.
4649 * We configure the default implementation of a debug adapter here.
@@ -104,7 +107,7 @@ export class ASDebugSession extends LoggingDebugSession
104107 response . body . supportsEvaluateForHovers = true ;
105108 response . body . supportsExceptionInfoRequest = true ;
106109
107- unreal . connect ( ) ;
110+ unreal . connect ( this . port ) ;
108111 unreal . sendRequestBreakFilters ( ) ;
109112
110113 this . waitingInitializeResponse = response ;
@@ -155,7 +158,7 @@ export class ASDebugSession extends LoggingDebugSession
155158 // make sure to 'Stop' the buffered logging if 'trace' is not set
156159 logger . setup ( args . trace ? Logger . LogLevel . Verbose : Logger . LogLevel . Stop , false ) ;
157160
158- unreal . connect ( ) ;
161+ unreal . connect ( args . port !== undefined ? args . port : this . port ) ;
159162 unreal . sendStartDebugging ( ) ;
160163
161164 for ( let clientPath of this . breakpoints . keys ( ) )
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ export function activate(context: ExtensionContext) {
140140class ASConfigurationProvider implements vscode . DebugConfigurationProvider {
141141
142142 private _server ?: Net . Server ;
143+ private _config ?: DebugConfiguration ;
143144
144145 /**
145146 * Massage a debug configuration just before a debug session is being launched,
@@ -159,22 +160,25 @@ class ASConfigurationProvider implements vscode.DebugConfigurationProvider {
159160 }
160161 }
161162
163+ let port = config . port ;
162164 if ( EMBED_DEBUG_ADAPTER ) {
163165 // start port listener on launch of first debug session
164- if ( ! this . _server ) {
165-
166+ // or if the port changed
167+ if ( ! this . _server || ( this . _server && port != this . _config . port ) ) {
166168 // start listening on a random port
167169 this . _server = Net . createServer ( socket => {
168170 const session = new ASDebugSession ( ) ;
169171 session . setRunAsServer ( true ) ;
172+ if ( port !== undefined )
173+ session . port = port ;
170174 session . start ( < NodeJS . ReadableStream > socket , socket ) ;
171175 } ) . listen ( 0 ) ;
172176 }
173177
174178 // make VS Code connect to debug server instead of launching debug adapter
175179 config . debugServer = this . _server . address ( ) . port ;
176180 }
177-
181+ this . _config = config ;
178182 return config ;
179183 }
180184
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ let unreal : Socket | null = null;
156156export let connected = false ;
157157export let events = new EventEmitter ( ) ;
158158
159- export function connect ( )
159+ export function connect ( port : number )
160160{
161161 if ( unreal != null )
162162 {
@@ -166,7 +166,7 @@ export function connect()
166166 unreal = new Socket ;
167167 connected = true ;
168168 //connection.console.log('Connecting to unreal editor...');
169- unreal . connect ( 28099 , "localhost" , function ( )
169+ unreal . connect ( port , "localhost" , function ( )
170170 {
171171 //connection.console.log('Connection to unreal editor established.');
172172 } ) ;
Original file line number Diff line number Diff line change 6565 "type" : " boolean" ,
6666 "description" : " Enable logging of the Debug Adapter Protocol." ,
6767 "default" : true
68+ },
69+ "port" : {
70+ "type" : " number" ,
71+ "description" : " Port to AS debug server" ,
72+ "default:" : 28099
6873 }
6974 }
7075 }
You can’t perform that action at this time.
0 commit comments