| OLD | NEW |
| 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 library socket.server; | 5 library socket.server; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/channel.dart'; | 8 import 'package:analysis_server/src/channel.dart'; |
| 9 import 'package:analysis_server/src/domain_context.dart'; | 9 import 'package:analysis_server/src/domain_context.dart'; |
| 10 import 'package:analysis_server/src/domain_server.dart'; | 10 import 'package:analysis_server/src/domain_server.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * connection, or `null` if no such connection has yet been established. | 22 * connection, or `null` if no such connection has yet been established. |
| 23 */ | 23 */ |
| 24 AnalysisServer analysisServer; | 24 AnalysisServer analysisServer; |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Create an analysis server which will communicate with the client using the | 27 * Create an analysis server which will communicate with the client using the |
| 28 * given serverChannel. | 28 * given serverChannel. |
| 29 */ | 29 */ |
| 30 void createAnalysisServer(ServerCommunicationChannel serverChannel) { | 30 void createAnalysisServer(ServerCommunicationChannel serverChannel) { |
| 31 if (analysisServer != null) { | 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(); | 32 var error = new RequestError.serverAlreadyStarted(); |
| 35 serverChannel.sendResponse(new Response('', error)); | 33 serverChannel.sendResponse(new Response('', error)); |
| 36 serverChannel.listen((Request request) { | 34 serverChannel.listen((Request request) { |
| 37 serverChannel.sendResponse(new Response(request.id, error)); | 35 serverChannel.sendResponse(new Response(request.id, error)); |
| 38 }); | 36 }); |
| 39 return; | 37 return; |
| 40 } | 38 } |
| 41 analysisServer = new AnalysisServer(serverChannel); | 39 analysisServer = new AnalysisServer(serverChannel); |
| 42 _initializeHandlers(analysisServer); | 40 _initializeHandlers(analysisServer); |
| 43 analysisServer.run(); | 41 analysisServer.run(); |
| 44 } | 42 } |
| 45 | 43 |
| 46 /** | 44 /** |
| 47 * Initialize the handlers to be used by the given [server]. | 45 * Initialize the handlers to be used by the given [server]. |
| 48 */ | 46 */ |
| 49 void _initializeHandlers(AnalysisServer server) { | 47 void _initializeHandlers(AnalysisServer server) { |
| 50 server.handlers = [ | 48 server.handlers = [ |
| 51 new ServerDomainHandler(server), | 49 new ServerDomainHandler(server), |
| 52 new ContextDomainHandler(server), | 50 new ContextDomainHandler(server), |
| 53 ]; | 51 ]; |
| 54 } | 52 } |
| 55 | 53 |
| 56 } | 54 } |
| OLD | NEW |