| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library http_parser.web_socket; | 5 library http_parser.web_socket; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 /// default); if it's a client, [serverSide] should be `false`. | 79 /// default); if it's a client, [serverSide] should be `false`. |
| 80 /// | 80 /// |
| 81 /// [WebSocket handshake]: https://tools.ietf.org/html/rfc6455#section-4 | 81 /// [WebSocket handshake]: https://tools.ietf.org/html/rfc6455#section-4 |
| 82 factory CompatibleWebSocket(Stream<List<int>> stream, | 82 factory CompatibleWebSocket(Stream<List<int>> stream, |
| 83 {StreamSink<List<int>> sink, bool serverSide: true}) { | 83 {StreamSink<List<int>> sink, bool serverSide: true}) { |
| 84 if (sink == null) { | 84 if (sink == null) { |
| 85 if (stream is! StreamSink) { | 85 if (stream is! StreamSink) { |
| 86 throw new ArgumentError("If stream isn't also a StreamSink, sink must " | 86 throw new ArgumentError("If stream isn't also a StreamSink, sink must " |
| 87 "be passed explicitly."); | 87 "be passed explicitly."); |
| 88 } | 88 } |
| 89 sink = stream; | 89 sink = stream as StreamSink; |
| 90 } | 90 } |
| 91 | 91 |
| 92 return new _WebSocketImpl._fromSocket(stream, sink, serverSide); | 92 return new _WebSocketImpl._fromSocket(stream, sink, serverSide); |
| 93 } | 93 } |
| 94 | 94 |
| 95 /// Closes the web socket connection. | 95 /// Closes the web socket connection. |
| 96 /// | 96 /// |
| 97 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent | 97 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent |
| 98 /// to the remote peer, respectively. If they are omitted, the peer will see | 98 /// to the remote peer, respectively. If they are omitted, the peer will see |
| 99 /// a "no status received" code with no reason. | 99 /// a "no status received" code with no reason. |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 code == _WebSocketStatus.RESERVED_1004 || | 927 code == _WebSocketStatus.RESERVED_1004 || |
| 928 code == _WebSocketStatus.NO_STATUS_RECEIVED || | 928 code == _WebSocketStatus.NO_STATUS_RECEIVED || |
| 929 code == _WebSocketStatus.ABNORMAL_CLOSURE || | 929 code == _WebSocketStatus.ABNORMAL_CLOSURE || |
| 930 (code > _WebSocketStatus.INTERNAL_SERVER_ERROR && | 930 (code > _WebSocketStatus.INTERNAL_SERVER_ERROR && |
| 931 code < _WebSocketStatus.RESERVED_1015) || | 931 code < _WebSocketStatus.RESERVED_1015) || |
| 932 (code >= _WebSocketStatus.RESERVED_1015 && | 932 (code >= _WebSocketStatus.RESERVED_1015 && |
| 933 code < 3000)); | 933 code < 3000)); |
| 934 } | 934 } |
| 935 } | 935 } |
| 936 | 936 |
| OLD | NEW |