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

Unified Diff: lib/src/server.dart

Issue 810333007: Add a done getter to Client, Server, and Peer. (Closed) Base URL: git@github.com:dart-lang/json_rpc_2@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « lib/src/peer.dart ('k') | lib/src/two_way_stream.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/server.dart
diff --git a/lib/src/server.dart b/lib/src/server.dart
index bd243de73230f35d5db3d281b553c74a409995e6..4458e0e5919ee65e5ea3ed2a6ce6f20820a6d714 100644
--- a/lib/src/server.dart
+++ b/lib/src/server.dart
@@ -38,6 +38,11 @@ class Server {
/// [RpcException.methodNotFound] exception.
final _fallbacks = new Queue<Function>();
+ /// Returns a [Future] that completes when the connection is closed.
+ ///
+ /// This is the same future that's returned by [listen].
+ Future get done => _streams.done;
+
/// Creates a [Server] that reads requests from [requests] and writes
/// responses to [responses].
///
@@ -135,7 +140,9 @@ class Server {
var nonNull = results.where((result) => result != null);
return nonNull.isEmpty ? null : nonNull.toList();
});
- }).then(_streams.add);
+ }).then((response) {
+ if (response != null) _streams.add(response);
+ });
}
/// Handles an individual parsed request.
« no previous file with comments | « lib/src/peer.dart ('k') | lib/src/two_way_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698