Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/ipc/electron-browser/mainProcessService.ts
3294 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Disposable } from '../../../base/common/lifecycle.js';
7
import { IChannel, IServerChannel } from '../../../base/parts/ipc/common/ipc.js';
8
import { Client as IPCElectronClient } from '../../../base/parts/ipc/electron-browser/ipc.electron.js';
9
import { IMainProcessService } from '../common/mainProcessService.js';
10
11
/**
12
* An implementation of `IMainProcessService` that leverages Electron's IPC.
13
*/
14
export class ElectronIPCMainProcessService extends Disposable implements IMainProcessService {
15
16
declare readonly _serviceBrand: undefined;
17
18
private mainProcessConnection: IPCElectronClient;
19
20
constructor(
21
windowId: number
22
) {
23
super();
24
25
this.mainProcessConnection = this._register(new IPCElectronClient(`window:${windowId}`));
26
}
27
28
getChannel(channelName: string): IChannel {
29
return this.mainProcessConnection.getChannel(channelName);
30
}
31
32
registerChannel(channelName: string, channel: IServerChannel<string>): void {
33
this.mainProcessConnection.registerChannel(channelName, channel);
34
}
35
}
36
37