Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/ipc/common/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 { IChannel, IPCServer, IServerChannel, StaticRouter } from '../../../base/parts/ipc/common/ipc.js';
7
import { createDecorator } from '../../instantiation/common/instantiation.js';
8
import { IRemoteService } from './services.js';
9
10
export const IMainProcessService = createDecorator<IMainProcessService>('mainProcessService');
11
12
export interface IMainProcessService extends IRemoteService { }
13
14
/**
15
* An implementation of `IMainProcessService` that leverages `IPCServer`.
16
*/
17
export class MainProcessService implements IMainProcessService {
18
19
declare readonly _serviceBrand: undefined;
20
21
constructor(
22
private server: IPCServer,
23
private router: StaticRouter
24
) { }
25
26
getChannel(channelName: string): IChannel {
27
return this.server.getChannel(channelName, this.router);
28
}
29
30
registerChannel(channelName: string, channel: IServerChannel<string>): void {
31
this.server.registerChannel(channelName, channel);
32
}
33
}
34
35