OLD | NEW |
| (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 stdio.server; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:io'; | |
9 | |
10 import 'package:analysis_server/src/channel/byte_stream_channel.dart'; | |
11 import 'package:analysis_server/src/socket_server.dart'; | |
12 | |
13 /** | |
14 * Instances of the class [StdioServer] implement a simple server operating | |
15 * over standard input and output. The primary responsibility of this server | |
16 * is to split incoming messages on newlines and pass them along to the | |
17 * analysis server. | |
18 */ | |
19 class StdioAnalysisServer { | |
20 /** | |
21 * An object that can handle either a WebSocket connection or a connection | |
22 * to the client over stdio. | |
23 */ | |
24 SocketServer socketServer; | |
25 | |
26 /** | |
27 * Initialize a newly created stdio server. | |
28 */ | |
29 StdioAnalysisServer(this.socketServer); | |
30 | |
31 /** | |
32 * Begin serving requests over stdio. | |
33 * | |
34 * Return a future that will be completed when stdin closes. | |
35 */ | |
36 Future serveStdio() { | |
37 ByteStreamServerChannel serverChannel = new ByteStreamServerChannel( | |
38 stdin, | |
39 stdout, | |
40 socketServer.instrumentationService); | |
41 socketServer.createAnalysisServer(serverChannel); | |
42 return serverChannel.closed; | |
43 } | |
44 } | |
OLD | NEW |