| OLD | NEW |
| 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 class _WebSocketMessageType { | 9 class _WebSocketMessageType { |
| 10 static const int NONE = 0; | 10 static const int NONE = 0; |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 | 859 |
| 860 Future close([int code, String reason]) { | 860 Future close([int code, String reason]) { |
| 861 if (!_writeClosed) { | 861 if (!_writeClosed) { |
| 862 if (_isReservedStatusCode(code)) { | 862 if (_isReservedStatusCode(code)) { |
| 863 throw new WebSocketException("Reserved status code $code"); | 863 throw new WebSocketException("Reserved status code $code"); |
| 864 } | 864 } |
| 865 _outCloseCode = code; | 865 _outCloseCode = code; |
| 866 _outCloseReason = reason; | 866 _outCloseReason = reason; |
| 867 _writeClosed = true; | 867 _writeClosed = true; |
| 868 } | 868 } |
| 869 if (!_sink._isBound) _sink.close(); | 869 if (!(_sink as _StreamSinkImpl)._isBound) _sink.close(); |
| 870 return _sink.done; | 870 return _sink.done; |
| 871 } | 871 } |
| 872 | 872 |
| 873 static bool _isReservedStatusCode(int code) { | 873 static bool _isReservedStatusCode(int code) { |
| 874 return code != null && | 874 return code != null && |
| 875 (code < WebSocketStatus.NORMAL_CLOSURE || | 875 (code < WebSocketStatus.NORMAL_CLOSURE || |
| 876 code == WebSocketStatus.RESERVED_1004 || | 876 code == WebSocketStatus.RESERVED_1004 || |
| 877 code == WebSocketStatus.NO_STATUS_RECEIVED || | 877 code == WebSocketStatus.NO_STATUS_RECEIVED || |
| 878 code == WebSocketStatus.ABNORMAL_CLOSURE || | 878 code == WebSocketStatus.ABNORMAL_CLOSURE || |
| 879 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && | 879 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && |
| 880 code < WebSocketStatus.RESERVED_1015) || | 880 code < WebSocketStatus.RESERVED_1015) || |
| 881 (code >= WebSocketStatus.RESERVED_1015 && | 881 (code >= WebSocketStatus.RESERVED_1015 && |
| 882 code < 3000)); | 882 code < 3000)); |
| 883 } | 883 } |
| 884 } | 884 } |
| OLD | NEW |