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

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

Issue 237643003: Split analysis server's HttpAnalysisServer into two classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing initialization of socketServer. Created 6 years, 8 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library socket.server;
6
7 import 'package:analysis_server/src/analysis_server.dart';
8 import 'package:analysis_server/src/channel.dart';
9 import 'package:analysis_server/src/domain_context.dart';
10 import 'package:analysis_server/src/domain_server.dart';
11 import 'package:analysis_server/src/protocol.dart';
12
13 /**
14 * Instances of the class [SocketServer] implement the common parts of
15 * http-based and stdio-based analysis servers. The primary responsibility of
16 * the SocketServer is to manage the lifetime of the AnalysisServer and to
17 * encode and decode the JSON messages exchanged with the client.
18 */
19 class SocketServer {
20 /**
21 * The analysis server that was created when a client established a
22 * connection, or `null` if no such connection has yet been established.
23 */
24 AnalysisServer analysisServer;
25
26 /**
27 * Create an analysis server which will communicate with the client using the
28 * given serverChannel.
29 */
30 void createAnalysisServer(ServerCommunicationChannel serverChannel) {
31 if (analysisServer != null) {
32 // TODO(paulberry): add a message to the protocol so that the server can
33 // inform the client of a successful connection.
34 var error = new RequestError.serverAlreadyStarted();
35 serverChannel.sendResponse(new Response('', error));
36 serverChannel.listen((Request request) {
37 serverChannel.sendResponse(new Response(request.id, error));
38 });
39 return;
40 }
41 analysisServer = new AnalysisServer(serverChannel);
42 _initializeHandlers(analysisServer);
43 analysisServer.run();
44 }
45
46 /**
47 * Initialize the handlers to be used by the given [server].
48 */
49 void _initializeHandlers(AnalysisServer server) {
50 server.handlers = [
51 new ServerDomainHandler(server),
52 new ContextDomainHandler(server),
53 ];
54 }
55
56 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/get_handler.dart ('k') | pkg/analysis_server/test/socket_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698