提交 b6b7bf91 编写于 作者: S Sandeep Somavarapu

ChoiceService: ipc

上级 e971497c
......@@ -30,8 +30,10 @@ import { TelemetryAppenderChannel } from 'vs/platform/telemetry/common/telemetry
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
import { ISharedProcessInitData } from './sharedProcess';
import {IChoiceService} from 'vs/platform/message/common/message';
import {ChoiceChannelClient} from 'vs/platform/message/common/messageIpc';
import { WindowEventChannelClient } from 'vs/code/common/windowsIpc';
import { IWindowEventService } from 'vs/code/common/windows';
import { IWindowEventService, ActiveWindowManager } from 'vs/code/common/windows';
function quit(err?: Error) {
if (err) {
......@@ -71,6 +73,13 @@ function main(server: Server, initData: ISharedProcessInitData): void {
}));
services.set(IWindowEventService, windowEventService);
const activeWindowManager = new ActiveWindowManager(windowEventService);
services.set(IChoiceService, new ChoiceChannelClient(server.getChannel('choice', {
routeCall: (command: any, arg: any) => {
return activeWindowManager.activeWindowId;
}
})));
const instantiationService = new InstantiationService(services);
instantiationService.invokeFunction(accessor => {
......
......@@ -7,12 +7,10 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { IChoiceService/*, Severity*/ } from 'vs/platform/message/common/message';
// TODO@Sandeep implement these guys
import { IChoiceService, Severity } from 'vs/platform/message/common/message';
export interface IChoiceChannel extends IChannel {
// call(command: 'getInstalled'): TPromise<ILocalExtension[]>;
call(command: 'choose'): TPromise<number>;
call(command: string, arg: any): TPromise<any>;
}
......@@ -21,22 +19,22 @@ export class ChoiceChannel implements IChoiceChannel {
constructor(private service: IChoiceService) {
}
call(command: string, arg: any): TPromise<any> {
call(command: string, args: any): TPromise<any> {
switch (command) {
// case 'getInstalled': return this.service.getInstalled(arg);
case 'choose': return this.service.choose(<Severity>args[0], <string>args[1], <string[]>args[2]);
}
return TPromise.wrapError('invalid command');
}
}
export class ChoiceChannelClient /*implements IChoiceService*/ {
export class ChoiceChannelClient implements IChoiceService {
_serviceBrand: any;
constructor(private channel: IChoiceChannel) { }
// getInstalled(type: LocalExtensionType = null): TPromise<ILocalExtension[]> {
// return this.channel.call('getInstalled', type);
// }
choose(severity: Severity, message: string, options: string[]): TPromise<number> {
return this.channel.call('choose', [severity, message, options]);
}
}
\ No newline at end of file
......@@ -59,6 +59,7 @@ import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
import {IMarkerService} from 'vs/platform/markers/common/markers';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
import {IMessageService, IChoiceService, Severity} from 'vs/platform/message/common/message';
import {ChoiceChannel} from 'vs/platform/message/common/messageIpc';
import {ISearchService} from 'vs/platform/search/common/search';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import {ICommandService} from 'vs/platform/commands/common/commands';
......@@ -228,6 +229,9 @@ export class WorkbenchShell {
const sharedProcess = connectNet(this.environmentService.sharedIPCHandle, `window:${ this.windowService.getWindowId() }`);
sharedProcess.done(client => {
client.registerChannel('choice', new ChoiceChannel(this.messageService));
client.onClose(() => {
this.messageService.show(Severity.Error, {
message: nls.localize('sharedProcessCrashed', "The shared process terminated unexpectedly. Please reload the window to recover."),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册