f548643064
R=brianwilkerson@google.com Review URL: https://codereview.chromium.org//235953019 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35116 260f80e4-7a28-3924-810f-c04153c831b5
43 lines
1.2 KiB
Dart
43 lines
1.2 KiB
Dart
// 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 stdio.server;
|
|
|
|
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:analysis_server/src/channel.dart';
|
|
import 'package:analysis_server/src/socket_server.dart';
|
|
|
|
/**
|
|
* Instances of the class [StdioServer] implement a simple server operating
|
|
* over standard input and output. The primary responsibility of this server
|
|
* is to split incoming messages on newlines and pass them along to the
|
|
* analysis server.
|
|
*/
|
|
class StdioAnalysisServer {
|
|
/**
|
|
* An object that can handle either a WebSocket connection or a connection
|
|
* to the client over stdio.
|
|
*/
|
|
SocketServer socketServer;
|
|
|
|
/**
|
|
* Initialize a newly created stdio server.
|
|
*/
|
|
StdioAnalysisServer(this.socketServer);
|
|
|
|
/**
|
|
* Begin serving requests over stdio.
|
|
*
|
|
* Return a future that will be completed when stdin closes.
|
|
*/
|
|
Future serveStdio() {
|
|
ByteStreamServerChannel serverChannel = new ByteStreamServerChannel(stdin,
|
|
stdout);
|
|
socketServer.createAnalysisServer(serverChannel);
|
|
return serverChannel.closed;
|
|
}
|
|
}
|