Introduce Remote Terminals

Co-authored-by: Rob Lourens <roblourens@gmail.com>
This commit is contained in:
Alex Dima
2020-10-14 22:39:28 +02:00
parent 2fcea93f82
commit 35368d6c01
9 changed files with 576 additions and 25 deletions

View File

@@ -34,12 +34,18 @@ export interface RunCommandPipeArgs {
args: any[];
}
export class CLIServer {
export interface ICommandsExecuter {
executeCommand<T>(id: string, ...args: any[]): Promise<T>;
}
private _server: http.Server;
private _ipcHandlePath: string | undefined;
export class CLIServerBase {
private readonly _server: http.Server;
constructor(@IExtHostCommands private _commands: IExtHostCommands, @ILogService private logService: ILogService) {
constructor(
private readonly _commands: ICommandsExecuter,
private readonly logService: ILogService,
private readonly _ipcHandlePath: string,
) {
this._server = http.createServer((req, res) => this.onRequest(req, res));
this.setup().catch(err => {
logService.error(err);
@@ -52,8 +58,6 @@ export class CLIServer {
}
private async setup(): Promise<string> {
this._ipcHandlePath = createRandomIPCHandle();
try {
this._server.listen(this.ipcHandlePath);
this._server.on('error', err => this.logService.error(err));
@@ -176,3 +180,12 @@ export class CLIServer {
}
}
}
export class CLIServer extends CLIServerBase {
constructor(
@IExtHostCommands commands: IExtHostCommands,
@ILogService logService: ILogService
) {
super(commands, logService, createRandomIPCHandle());
}
}