| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:html'; | 6 import 'dart:html'; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:async/async.dart'; | 9 import 'package:async/async.dart'; |
| 10 import 'package:stream_channel/stream_channel.dart'; | 10 import 'package:stream_channel/stream_channel.dart'; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 onDone: () => _webSocket.close(_localCloseCode, _localCloseReason)); | 108 onDone: () => _webSocket.close(_localCloseCode, _localCloseReason)); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 /// A [WebSocketSink] that tracks the close code and reason passed to [close]. | 112 /// A [WebSocketSink] that tracks the close code and reason passed to [close]. |
| 113 class _HtmlWebSocketSink extends DelegatingStreamSink implements WebSocketSink { | 113 class _HtmlWebSocketSink extends DelegatingStreamSink implements WebSocketSink { |
| 114 /// The channel to which this sink belongs. | 114 /// The channel to which this sink belongs. |
| 115 final HtmlWebSocketChannel _channel; | 115 final HtmlWebSocketChannel _channel; |
| 116 | 116 |
| 117 _HtmlWebSocketSink(HtmlWebSocketChannel channel) | 117 _HtmlWebSocketSink(HtmlWebSocketChannel channel) |
| 118 : super(channel._controller.foreign.sink), | 118 : _channel = channel, |
| 119 _channel = channel; | 119 super(channel._controller.foreign.sink); |
| 120 | 120 |
| 121 Future close([int closeCode, String closeReason]) { | 121 Future close([int closeCode, String closeReason]) { |
| 122 _channel._localCloseCode = closeCode; | 122 _channel._localCloseCode = closeCode; |
| 123 _channel._localCloseReason = closeReason; | 123 _channel._localCloseReason = closeReason; |
| 124 return super.close(); | 124 return super.close(); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 /// An enum for choosing what type [HtmlWebSocketChannel] emits for binary | 128 /// An enum for choosing what type [HtmlWebSocketChannel] emits for binary |
| 129 /// messages. | 129 /// messages. |
| 130 class BinaryType { | 130 class BinaryType { |
| 131 /// Tells the channel to emit binary messages as [Blob]s. | 131 /// Tells the channel to emit binary messages as [Blob]s. |
| 132 static const blob = const BinaryType._("blob", "blob"); | 132 static const blob = const BinaryType._("blob", "blob"); |
| 133 | 133 |
| 134 /// Tells the channel to emit binary messages as [Uint8List]s. | 134 /// Tells the channel to emit binary messages as [Uint8List]s. |
| 135 static const list = const BinaryType._("list", "arraybuffer"); | 135 static const list = const BinaryType._("list", "arraybuffer"); |
| 136 | 136 |
| 137 /// The name of the binary type, which matches its variable name. | 137 /// The name of the binary type, which matches its variable name. |
| 138 final String name; | 138 final String name; |
| 139 | 139 |
| 140 /// The value as understood by the underlying [WebSocket] API. | 140 /// The value as understood by the underlying [WebSocket] API. |
| 141 final String value; | 141 final String value; |
| 142 | 142 |
| 143 const BinaryType._(this.name, this.value); | 143 const BinaryType._(this.name, this.value); |
| 144 | 144 |
| 145 String toString() => name; | 145 String toString() => name; |
| 146 } | 146 } |
| OLD | NEW |