Path: blob/main/src/vs/platform/ipc/electron-browser/mainProcessService.ts
3294 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Disposable } from '../../../base/common/lifecycle.js';6import { IChannel, IServerChannel } from '../../../base/parts/ipc/common/ipc.js';7import { Client as IPCElectronClient } from '../../../base/parts/ipc/electron-browser/ipc.electron.js';8import { IMainProcessService } from '../common/mainProcessService.js';910/**11* An implementation of `IMainProcessService` that leverages Electron's IPC.12*/13export class ElectronIPCMainProcessService extends Disposable implements IMainProcessService {1415declare readonly _serviceBrand: undefined;1617private mainProcessConnection: IPCElectronClient;1819constructor(20windowId: number21) {22super();2324this.mainProcessConnection = this._register(new IPCElectronClient(`window:${windowId}`));25}2627getChannel(channelName: string): IChannel {28return this.mainProcessConnection.getChannel(channelName);29}3031registerChannel(channelName: string, channel: IServerChannel<string>): void {32this.mainProcessConnection.registerChannel(channelName, channel);33}34}353637