Skip to content

Commit

Permalink
Update conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
osa1 committed Dec 8, 2023
1 parent 08fdebf commit a5011a2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,17 @@ class HtmlWebSocketChannel extends StreamChannelMixin
}

void _innerListen(MessageEvent event) {
var data = event.data.dartify();
if (data is ByteBuffer) {
data = data.asUint8List();
// Event data will be ArrayBuffer, Blob, or String.
final eventData = event.data;
final Object? data;
if (eventData.typeofEquals('string')) {
data = (eventData as JSString).toDart;
} else if (eventData.typeofEquals('object') &&
(eventData as JSObject).instanceOfString('ArrayBuffer')) {
data = (eventData as JSArrayBuffer).toDart;
} else {
// Blobs are passed directly.
data = eventData;
}
_controller.local.sink.add(data);
}
Expand Down

0 comments on commit a5011a2

Please sign in to comment.