Skip to content

Commit

Permalink
add a workaround for dart-lang/sdk#27414
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Jul 20, 2018
1 parent 549068a commit 53b0774
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/src/engine/transport/websocket_transport.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
/**
* websocket_transport.dart
*
Expand All @@ -18,10 +19,11 @@ class WebSocketTransport extends Transport {
static Logger _logger = new Logger('socket_io:transport.WebSocketTransport');
bool get handlesUpgrades => true;
bool get supportsFraming => true;
StreamSubscription subscription;
WebSocketTransport(connect): super(connect) {
this.name = 'websocket';
this.connect = connect;
connect.websocket.listen(this.onData, onError: this.onError, onDone: this.onClose);
subscription = connect.websocket.listen(this.onData, onError: this.onError, onDone: this.onClose);
writable = true;
}

Expand Down Expand Up @@ -56,6 +58,15 @@ class WebSocketTransport extends Transport {
PacketParser.encodePacket(packet, supportsBinary: this.supportsBinary, callback: (_) => send(_, packet));
}
}
void onClose() {
super.onClose();

// workaround for https://github.com/dart-lang/sdk/issues/27414
if (subscription != null) {
subscription.cancel();
subscription = null;
}
}
void doClose([fn]) {
this.connect.websocket.close();
if (fn != null)
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: socket_io
description: Dartlang port of socket.io
version: 0.8.1
version: 0.8.2
author: jumperchen <[email protected]>
homepage: https://www.zkoss.org

Expand Down

0 comments on commit 53b0774

Please sign in to comment.