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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/socket_server.dart
diff --git a/pkg/analysis_server/lib/src/socket_server.dart b/pkg/analysis_server/lib/src/socket_server.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3d5949f12ae5994907a350e3e93d3be7ca8b2296
--- /dev/null
+++ b/pkg/analysis_server/lib/src/socket_server.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library socket.server;
+
+import 'package:analysis_server/src/analysis_server.dart';
+import 'package:analysis_server/src/channel.dart';
+import 'package:analysis_server/src/domain_context.dart';
+import 'package:analysis_server/src/domain_server.dart';
+import 'package:analysis_server/src/protocol.dart';
+
+/**
+ * Instances of the class [SocketServer] implement the common parts of
+ * http-based and stdio-based analysis servers. The primary responsibility of
+ * the SocketServer is to manage the lifetime of the AnalysisServer and to
+ * encode and decode the JSON messages exchanged with the client.
+ */
+class SocketServer {
+ /**
+ * The analysis server that was created when a client established a
+ * connection, or `null` if no such connection has yet been established.
+ */
+ AnalysisServer analysisServer;
+
+ /**
+ * Create an analysis server which will communicate with the client using the
+ * given serverChannel.
+ */
+ void createAnalysisServer(ServerCommunicationChannel serverChannel) {
+ if (analysisServer != null) {
+ // TODO(paulberry): add a message to the protocol so that the server can
+ // inform the client of a successful connection.
+ var error = new RequestError.serverAlreadyStarted();
+ serverChannel.sendResponse(new Response('', error));
+ serverChannel.listen((Request request) {
+ serverChannel.sendResponse(new Response(request.id, error));
+ });
+ return;
+ }
+ analysisServer = new AnalysisServer(serverChannel);
+ _initializeHandlers(analysisServer);
+ analysisServer.run();
+ }
+
+ /**
+ * Initialize the handlers to be used by the given [server].
+ */
+ void _initializeHandlers(AnalysisServer server) {
+ server.handlers = [
+ new ServerDomainHandler(server),
+ new ContextDomainHandler(server),
+ ];
+ }
+
+}
« 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