Skip to content

Commit

Permalink
Fix #72 Can't send Iterable as one packet
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed May 5, 2020
1 parent 409a0de commit a31054c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.9.10

**Bug fix:**

* [#72](https://github.com/rikulo/socket.io-client-dart/issues/72) Can't send Iterable as one packet

## 0.9.9

**Bug fix:**
Expand Down
7 changes: 6 additions & 1 deletion lib/src/engine/transport/io_websocket_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
//import 'dart:html';
import 'package:logging/logging.dart';
import 'package:socket_io_client/src/engine/transport/transport.dart';
Expand Down Expand Up @@ -97,7 +98,11 @@ class IOWebSocketTransport extends Transport {
// throw an error
try {
// TypeError is thrown when passing the second argument on Safari
ws.add(data);
if (data is ByteBuffer) {
ws.add(data.asUint8List());
} else {
ws.add(data);
}
} catch (e) {
_logger.fine('websocket closed before onclose event');
}
Expand Down
6 changes: 5 additions & 1 deletion lib/src/socket.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:typed_data';

///
/// socket.dart
///
Expand Down Expand Up @@ -142,7 +144,9 @@ class Socket extends EventEmitter {
super.emit(event, data);
} else {
var sendData = <dynamic>[event];
if (data is Iterable) {
if (data is ByteBuffer || data is List<int>) {
sendData.add(data);
} else if (data is Iterable) {
sendData.addAll(data);
} else if (data != null) {
sendData.add(data);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: socket_io_client
description: Dartlang port of socket.io-client for web, flutter, dartvm to use
version: 0.9.9
version: 0.9.10
author: jumperchen <[email protected]>
homepage: https://www.zkoss.org
repository: https://github.com/rikulo/socket.io-client-dart
Expand All @@ -11,7 +11,7 @@ environment:

dependencies:
logging: ^0.11.3+2
socket_io_common: ">=0.9.0+5 <2.0.0"
socket_io_common: ">=0.9.2 <2.0.0"

dev_dependencies:
test: ">=1.3.0 <2.0.0"
Expand Down

0 comments on commit a31054c

Please sign in to comment.