Files
azuredatastudio/src/vs/platform/ipc/electron-browser/mainProcessService.ts
Anthony Dresser ea0f9e6ce9 Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
2019-09-15 22:38:26 -07:00

44 lines
1.5 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
import { Client } from 'vs/base/parts/ipc/electron-browser/ipc.electron-browser';
import { Disposable } from 'vs/base/common/lifecycle';
export const IMainProcessService = createDecorator<IMainProcessService>('mainProcessService');
export interface IMainProcessService {
_serviceBrand: undefined;
getChannel(channelName: string): IChannel;
registerChannel(channelName: string, channel: IServerChannel<string>): void;
}
export class MainProcessService extends Disposable implements IMainProcessService {
_serviceBrand: undefined;
private mainProcessConnection: Client;
constructor(
windowId: number
) {
super();
this.mainProcessConnection = this._register(new Client(`window:${windowId}`));
}
getChannel(channelName: string): IChannel {
return this.mainProcessConnection.getChannel(channelName);
}
registerChannel(channelName: string, channel: IServerChannel<string>): void {
this.mainProcessConnection.registerChannel(channelName, channel);
}
}