Skip to content

Commit 2f8b0be

Browse files
committed
Fix [websocket connection cannot be established in WASM mode](#412 (comment))
1 parent 8f9fcec commit 2f8b0be

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.1.0+2
2+
3+
**Bug fix:**
4+
* [websocket connection cannot be established in WASM mode](https://github.com/rikulo/socket.io-client-dart/pull/412#issuecomment-2756685758)
5+
16
## 3.1.0+1
27

38
**Bug fix:**

lib/src/engine/transport/websocket_transport.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// History: 26/04/2017
33
// Author: jumperchen<[email protected]>
44

5+
import 'dart:js_interop';
56
import 'dart:async';
67
import 'package:web/web.dart';
78
import 'package:logging/logging.dart';
@@ -83,7 +84,11 @@ class WebSocketTransport extends Transport {
8384
// throw an error
8485
try {
8586
// TypeError is thrown when passing the second argument on Safari
86-
ws!.send(data);
87+
if (data is String) {
88+
ws!.send(data.toJS); // fix for WASM
89+
} else {
90+
ws!.send(data);
91+
}
8792
} catch (e) {
8893
_logger.fine('websocket closed before onclose event');
8994
}

pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: socket_io_client
22
description: Dartlang port of socket.io-client for web, flutter, dartvm to use
3-
version: 3.1.0+1
3+
version: 3.1.0+2
44
homepage: https://www.zkoss.org
55
repository: https://github.com/rikulo/socket.io-client-dart
66
issue_tracker: https://github.com/rikulo/socket.io-client-dart/issues
@@ -10,7 +10,7 @@ environment:
1010

1111
dependencies:
1212
logging: '^1.2.0'
13-
socket_io_common: '^3.0.2'
13+
socket_io_common: '^3.1.0'
1414
web: ^1.1.0
1515

1616
dev_dependencies:

0 commit comments

Comments
 (0)