Skip to content

Commit

Permalink
Update to handle Socket implements Stream<Uint8List> (flutter#65)
Browse files Browse the repository at this point in the history
A recent change in the Dart SDK updated `Socket` to
implement `Stream<Uint8List>` rather than `Stream<List<int>>`.
This forwards compatible change calls `StreamTransformer.bind()`
rather than `Stream.transform()`, thus putting the stream in a
covariant position and allowing for the transition to `Uint8List`.

dart-lang/sdk#36900
  • Loading branch information
tvolkert authored and kevmoo committed Jul 9, 2019
1 parent 7b5a488 commit 2342e4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.14

* Updates to handle `Socket implements Stream<Uint8List>`

## 1.0.13

* Internal changes for consistency with the Dart SDK.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/copy/web_socket_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ class _WebSocketConsumer implements StreamConsumer {
onResume: _onResume,
onCancel: _onListen);
var stream =
_controller.stream.transform(_WebSocketOutgoingTransformer(webSocket));
_WebSocketOutgoingTransformer(webSocket).bind(_controller.stream);
sink.addStream(stream).then((_) {
_done();
_closeCompleter.complete(webSocket);
Expand Down Expand Up @@ -709,7 +709,7 @@ class WebSocketImpl extends Stream with _ServiceObject implements StreamSink {
_readyState = WebSocket.OPEN;

var transformer = _WebSocketProtocolTransformer(_serverSide);
_subscription = stream.transform(transformer).listen((data) {
_subscription = transformer.bind(stream).listen((data) {
if (data is _WebSocketPing) {
if (!_writeClosed) _consumer.add(_WebSocketPong(data.payload));
} else if (data is _WebSocketPong) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: web_socket_channel
version: 1.0.13
version: 1.0.14

description: >-
StreamChannel wrappers for WebSockets. Provides a cross-platform
Expand Down

0 comments on commit 2342e4e

Please sign in to comment.