mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-18 06:09:20 +01:00
ea048b8771
related to #114418
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
|
import { Client as IPCElectronClient } from 'vs/base/parts/ipc/electron-sandbox/ipc.electron';
|
|
import { Disposable } from 'vs/base/common/lifecycle';
|
|
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/services';
|
|
|
|
/**
|
|
* An implementation of `IMainProcessService` that leverages Electron's IPC.
|
|
*/
|
|
export class ElectronIPCMainProcessService extends Disposable implements IMainProcessService {
|
|
|
|
declare readonly _serviceBrand: undefined;
|
|
|
|
private mainProcessConnection: IPCElectronClient;
|
|
|
|
constructor(
|
|
windowId: number
|
|
) {
|
|
super();
|
|
|
|
this.mainProcessConnection = this._register(new IPCElectronClient(`window:${windowId}`));
|
|
}
|
|
|
|
getChannel(channelName: string): IChannel {
|
|
return this.mainProcessConnection.getChannel(channelName);
|
|
}
|
|
|
|
registerChannel(channelName: string, channel: IServerChannel<string>): void {
|
|
this.mainProcessConnection.registerChannel(channelName, channel);
|
|
}
|
|
}
|