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

Unified Diff: lib/src/server.dart

Issue 1328503003: Add Server.isClosed and Client.isClosed. (Closed) Base URL: git@github.com:dart-lang/json_rpc_2.git@master
Patch Set: Code review changes Created 5 years, 3 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 4458e0e5919ee65e5ea3ed2a6ce6f20820a6d714..4188e78cd5c724bc17ef6ca7e9a3e39656adfab5 100644
--- a/lib/src/server.dart
+++ b/lib/src/server.dart
@@ -43,6 +43,9 @@ class Server {
/// This is the same future that's returned by [listen].
Future get done => _streams.done;
+ /// Whether the connection is closed.
+ bool get isClosed => _streams.isClosed;
+
/// Creates a [Server] that reads requests from [requests] and writes
/// responses to [responses].
///
@@ -141,7 +144,7 @@ class Server {
return nonNull.isEmpty ? null : nonNull.toList();
});
}).then((response) {
- if (response != null) _streams.add(response);
+ if (!_streams.isClosed && response != null) _streams.add(response);
});
}
« 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