Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Side by Side Diff: pkg/analysis_server/lib/src/analysis_manager.dart

Issue 182903005: split client and server channels (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 import 'package:analysis_server/src/channel.dart'; 8 import 'package:analysis_server/src/channel.dart';
9 import 'package:analysis_server/src/domain_server.dart'; 9 import 'package:analysis_server/src/domain_server.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
11 11
12 /** 12 /**
13 * [AnalysisManager] is used to launch and manage an analysis server 13 * [AnalysisManager] is used to launch and manage an analysis server
14 * running in a separate process using either the [start] or [connect] methods. 14 * running in a separate process using either the [start] or [connect] methods.
15 */ 15 */
16 class AnalysisManager { 16 class AnalysisManager {
17 // TODO dynamically allocate port and/or allow client to specify port 17 // TODO dynamically allocate port and/or allow client to specify port
18 static const int PORT = 3333; 18 static const int PORT = 3333;
19 19
20 /** 20 /**
21 * The analysis server process being managed 21 * The analysis server process being managed
22 * or `null` if managing an analysis server that was already running. 22 * or `null` if managing an analysis server that was already running.
23 */ 23 */
24 Process process; 24 Process process;
25 25
26 /** 26 /**
27 * The channel used to communicate with the analysis server. 27 * The channel used to communicate with the analysis server.
28 */ 28 */
29 CommunicationChannel channel; 29 ClientCommunicationChannel channel;
30 30
31 /** 31 /**
32 * Launch analysis server in a separate process 32 * Launch analysis server in a separate process
33 * and return a future with a manager for that analysis server. 33 * and return a future with a manager for that analysis server.
34 */ 34 */
35 static Future<AnalysisManager> start(String serverPath) { 35 static Future<AnalysisManager> start(String serverPath) {
36 return new AnalysisManager()._launchServer(serverPath); 36 return new AnalysisManager()._launchServer(serverPath);
37 } 37 }
38 38
39 /** 39 /**
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 exitCode = 1; 93 exitCode = 1;
94 if (process != null) { 94 if (process != null) {
95 process.kill(); 95 process.kill();
96 } 96 }
97 throw 'Failed to connect to analysis server at $serverUrl\n $error'; 97 throw 'Failed to connect to analysis server at $serverUrl\n $error';
98 }; 98 };
99 try { 99 try {
100 return WebSocket.connect(serverUrl) 100 return WebSocket.connect(serverUrl)
101 .catchError(onError) 101 .catchError(onError)
102 .then((WebSocket socket) { 102 .then((WebSocket socket) {
103 this.channel = new WebSocketChannel(socket); 103 this.channel = new WebSocketClientChannel(socket);
104 return this; 104 return this;
105 }); 105 });
106 } catch (error) { 106 } catch (error) {
107 onError(error); 107 onError(error);
108 } 108 }
109 } 109 }
110 110
111 /** 111 /**
112 * Stop the analysis server. 112 * Stop the analysis server.
113 * 113 *
(...skipping 15 matching lines...) Expand all
129 }) 129 })
130 .then((result) { 130 .then((result) {
131 if (result != 0) { 131 if (result != 0) {
132 exitCode = result; 132 exitCode = result;
133 } 133 }
134 return true; 134 return true;
135 }); 135 });
136 } 136 }
137 137
138 } 138 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/http_server.dart ('k') | pkg/analysis_server/lib/src/analysis_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698