Index: sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart b/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart |
index 7952dcf9efabbf63cbf15ba62039f8824526e2ea..dc7b3c021fbd20bc41352ab3076f53f871cce4b9 100644 |
--- a/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart |
+++ b/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart |
@@ -20,11 +20,11 @@ import 'asset_environment.dart'; |
/// This is a [JSON-RPC 2.0](http://www.jsonrpc.org/specification) server. Its |
/// methods are described in the method-level documentation below. |
class WebSocketApi { |
- final CompatibleWebSocket _socket; |
final AssetEnvironment _environment; |
- final _server = new json_rpc.Server(); |
+ final json_rpc.Server _server; |
- WebSocketApi(this._socket, this._environment) { |
+ WebSocketApi(CompatibleWebSocket socket, this._environment) |
+ : _server = new json_rpc.Server(socket) { |
_server.registerMethod("urlToAssetId", _urlToAssetId); |
_server.registerMethod("pathToUrls", _pathToUrls); |
_server.registerMethod("serveDirectory", _serveDirectory); |
@@ -36,13 +36,7 @@ class WebSocketApi { |
/// Returns a future that completes when the socket has closed. It will |
/// complete with an error if the socket had an error, otherwise it will |
/// complete to `null`. |
- Future listen() { |
- return _socket.listen((request) { |
- _server.parseRequest(request).then((response) { |
- if (response != null) _socket.add(response); |
- }); |
- }, cancelOnError: true).asFuture(); |
- } |
+ Future listen() => _server.listen(); |
/// Given a URL to an asset that is served by pub, returns the ID of the |
/// asset that would be accessed by that URL. |