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

ChoiceService: ipc

上级 e971497c
...@@ -30,8 +30,10 @@ import { TelemetryAppenderChannel } from 'vs/platform/telemetry/common/telemetry ...@@ -30,8 +30,10 @@ import { TelemetryAppenderChannel } from 'vs/platform/telemetry/common/telemetry
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender'; import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
import { ISharedProcessInitData } from './sharedProcess'; 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 { 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) { function quit(err?: Error) {
if (err) { if (err) {
...@@ -71,6 +73,13 @@ function main(server: Server, initData: ISharedProcessInitData): void { ...@@ -71,6 +73,13 @@ function main(server: Server, initData: ISharedProcessInitData): void {
})); }));
services.set(IWindowEventService, windowEventService); 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); const instantiationService = new InstantiationService(services);
instantiationService.invokeFunction(accessor => { instantiationService.invokeFunction(accessor => {
...@@ -146,7 +155,7 @@ function setupIPC(hook: string): TPromise<Server> { ...@@ -146,7 +155,7 @@ function setupIPC(hook: string): TPromise<Server> {
} catch (e) { } catch (e) {
return TPromise.wrapError(new Error('Error deleting the shared ipc hook.')); return TPromise.wrapError(new Error('Error deleting the shared ipc hook.'));
} }
return setup(false); return setup(false);
} }
); );
......
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { IChannel } from 'vs/base/parts/ipc/common/ipc'; import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { IChoiceService/*, Severity*/ } from 'vs/platform/message/common/message'; import { IChoiceService, Severity } from 'vs/platform/message/common/message';
// TODO@Sandeep implement these guys
export interface IChoiceChannel extends IChannel { export interface IChoiceChannel extends IChannel {
// call(command: 'getInstalled'): TPromise<ILocalExtension[]>; call(command: 'choose'): TPromise<number>;
call(command: string, arg: any): TPromise<any>; call(command: string, arg: any): TPromise<any>;
} }
...@@ -21,22 +19,22 @@ export class ChoiceChannel implements IChoiceChannel { ...@@ -21,22 +19,22 @@ export class ChoiceChannel implements IChoiceChannel {
constructor(private service: IChoiceService) { constructor(private service: IChoiceService) {
} }
call(command: string, arg: any): TPromise<any> { call(command: string, args: any): TPromise<any> {
switch (command) { 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'); return TPromise.wrapError('invalid command');
} }
} }
export class ChoiceChannelClient /*implements IChoiceService*/ { export class ChoiceChannelClient implements IChoiceService {
_serviceBrand: any; _serviceBrand: any;
constructor(private channel: IChoiceChannel) { } constructor(private channel: IChoiceChannel) { }
// getInstalled(type: LocalExtensionType = null): TPromise<ILocalExtension[]> { choose(severity: Severity, message: string, options: string[]): TPromise<number> {
// return this.channel.call('getInstalled', type); 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'; ...@@ -59,6 +59,7 @@ import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
import {IMarkerService} from 'vs/platform/markers/common/markers'; import {IMarkerService} from 'vs/platform/markers/common/markers';
import {IEnvironmentService} from 'vs/platform/environment/common/environment'; import {IEnvironmentService} from 'vs/platform/environment/common/environment';
import {IMessageService, IChoiceService, Severity} from 'vs/platform/message/common/message'; 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 {ISearchService} from 'vs/platform/search/common/search';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import {ICommandService} from 'vs/platform/commands/common/commands'; import {ICommandService} from 'vs/platform/commands/common/commands';
...@@ -228,6 +229,9 @@ export class WorkbenchShell { ...@@ -228,6 +229,9 @@ export class WorkbenchShell {
const sharedProcess = connectNet(this.environmentService.sharedIPCHandle, `window:${ this.windowService.getWindowId() }`); const sharedProcess = connectNet(this.environmentService.sharedIPCHandle, `window:${ this.windowService.getWindowId() }`);
sharedProcess.done(client => { sharedProcess.done(client => {
client.registerChannel('choice', new ChoiceChannel(this.messageService));
client.onClose(() => { client.onClose(() => {
this.messageService.show(Severity.Error, { this.messageService.show(Severity.Error, {
message: nls.localize('sharedProcessCrashed', "The shared process terminated unexpectedly. Please reload the window to recover."), 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.
先完成此消息的编辑!
想要评论请 注册