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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart

Issue 309503005: Convert json_rpc.Server to take a Stream and StreamSink. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
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.
« pkg/json_rpc_2/lib/src/server.dart ('K') | « pkg/json_rpc_2/test/server/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698