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

Side by Side Diff: sdk/lib/io/websocket_impl.dart

Issue 1328123002: Revert "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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/standalone/io/web_socket_error_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
8 8
9 // Matches _WebSocketOpcode. 9 // Matches _WebSocketOpcode.
10 class _WebSocketMessageType { 10 class _WebSocketMessageType {
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 var protocol = response.headers.value('Sec-WebSocket-Protocol'); 850 var protocol = response.headers.value('Sec-WebSocket-Protocol');
851 return response.detachSocket() 851 return response.detachSocket()
852 .then((socket) => new _WebSocketImpl._fromSocket(socket, protocol)); 852 .then((socket) => new _WebSocketImpl._fromSocket(socket, protocol));
853 }); 853 });
854 } 854 }
855 855
856 _WebSocketImpl._fromSocket(this._socket, this.protocol, 856 _WebSocketImpl._fromSocket(this._socket, this.protocol,
857 [this._serverSide = false]) { 857 [this._serverSide = false]) {
858 _consumer = new _WebSocketConsumer(this, _socket); 858 _consumer = new _WebSocketConsumer(this, _socket);
859 _sink = new _StreamSinkImpl(_consumer); 859 _sink = new _StreamSinkImpl(_consumer);
860 _sink.done.catchError((e) {
861 if (!_controller.isClosed) {
862 _close(WebSocketStatus.ABNORMAL_CLOSURE);
863 _controller.addError(e);
864 _controller.close();
865 }
866 });
867 _readyState = WebSocket.OPEN; 860 _readyState = WebSocket.OPEN;
868 861
869 var transformer = new _WebSocketProtocolTransformer(_serverSide); 862 var transformer = new _WebSocketProtocolTransformer(_serverSide);
870 _subscription = _socket.transform(transformer).listen( 863 _subscription = _socket.transform(transformer).listen(
871 (data) { 864 (data) {
872 if (data is _WebSocketPing) { 865 if (data is _WebSocketPing) {
873 if (!_writeClosed) _consumer.add(new _WebSocketPong(data.payload)); 866 if (!_writeClosed) _consumer.add(new _WebSocketPong(data.payload));
874 } else if (data is _WebSocketPong) { 867 } else if (data is _WebSocketPong) {
875 // Simply set pingInterval, as it'll cancel any timers. 868 // Simply set pingInterval, as it'll cancel any timers.
876 pingInterval = _pingInterval; 869 pingInterval = _pingInterval;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 } 986 }
994 return _sink.close(); 987 return _sink.close();
995 } 988 }
996 989
997 void _close([int code, String reason]) { 990 void _close([int code, String reason]) {
998 if (_writeClosed) return; 991 if (_writeClosed) return;
999 if (_outCloseCode == null) { 992 if (_outCloseCode == null) {
1000 _outCloseCode = code; 993 _outCloseCode = code;
1001 _outCloseReason = reason; 994 _outCloseReason = reason;
1002 } 995 }
1003 if (_closeCode == null) {
1004 _closeCode = code;
1005 _closeReason = reason;
1006 }
1007 _writeClosed = true; 996 _writeClosed = true;
1008 _consumer.closeSocket(); 997 _consumer.closeSocket();
1009 _webSockets.remove(_serviceId); 998 _webSockets.remove(_serviceId);
1010 } 999 }
1011 1000
1012 String get _serviceTypePath => 'io/websockets'; 1001 String get _serviceTypePath => 'io/websockets';
1013 String get _serviceTypeName => 'WebSocket'; 1002 String get _serviceTypeName => 'WebSocket';
1014 1003
1015 Map _toJSON(bool ref) { 1004 Map _toJSON(bool ref) {
1016 var name = '${_socket.address.host}:${_socket.port}'; 1005 var name = '${_socket.address.host}:${_socket.port}';
(...skipping 24 matching lines...) Expand all
1041 (code < WebSocketStatus.NORMAL_CLOSURE || 1030 (code < WebSocketStatus.NORMAL_CLOSURE ||
1042 code == WebSocketStatus.RESERVED_1004 || 1031 code == WebSocketStatus.RESERVED_1004 ||
1043 code == WebSocketStatus.NO_STATUS_RECEIVED || 1032 code == WebSocketStatus.NO_STATUS_RECEIVED ||
1044 code == WebSocketStatus.ABNORMAL_CLOSURE || 1033 code == WebSocketStatus.ABNORMAL_CLOSURE ||
1045 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && 1034 (code > WebSocketStatus.INTERNAL_SERVER_ERROR &&
1046 code < WebSocketStatus.RESERVED_1015) || 1035 code < WebSocketStatus.RESERVED_1015) ||
1047 (code >= WebSocketStatus.RESERVED_1015 && 1036 (code >= WebSocketStatus.RESERVED_1015 &&
1048 code < 3000)); 1037 code < 3000));
1049 } 1038 }
1050 } 1039 }
OLDNEW
« 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