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

Unified Diff: sdk/lib/io/websocket_impl.dart

Issue 1304243005: Handle addError on a WebSocket (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 | « no previous file | tests/standalone/io/web_socket_error_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/websocket_impl.dart
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart
index cc68544e536233a5e43d63a699e01d4d58ce5b4e..af5f8426c983db0bc28902cb4bb5a82f4111f8d9 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -857,6 +857,13 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
[this._serverSide = false]) {
_consumer = new _WebSocketConsumer(this, _socket);
_sink = new _StreamSinkImpl(_consumer);
+ _sink.done.catchError((e) {
+ if (!_controller.isClosed) {
+ _close(WebSocketStatus.ABNORMAL_CLOSURE);
+ _controller.addError(e);
+ _controller.close();
+ }
+ });
_readyState = WebSocket.OPEN;
var transformer = new _WebSocketProtocolTransformer(_serverSide);
@@ -993,6 +1000,10 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
_outCloseCode = code;
_outCloseReason = reason;
}
+ if (_closeCode == null) {
+ _closeCode = code;
+ _closeReason = reason;
+ }
_writeClosed = true;
_consumer.closeSocket();
_webSockets.remove(_serviceId);
« no previous file with comments | « no previous file | tests/standalone/io/web_socket_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698