From df68a84f4257d771f8c165765710768c2701b4db Mon Sep 17 00:00:00 2001 From: Jumper Chen Date: Fri, 2 Feb 2018 16:26:13 +0800 Subject: [PATCH] fix rikulo/socket.io-client-dart#2 --- lib/src/engine/parser/parser.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/engine/parser/parser.dart b/lib/src/engine/parser/parser.dart index f31d9d3..78badd1 100644 --- a/lib/src/engine/parser/parser.dart +++ b/lib/src/engine/parser/parser.dart @@ -170,9 +170,15 @@ class PacketParser { return { 'type': type, 'data': data}; } + static hasBinary(List packets) { + return packets.any((map) { + final data = map['data']; + return data is ByteBuffer; + }); + } static encodePayload(List packets, {bool supportsBinary = false, callback(_)}) { - if (supportsBinary) { + if (supportsBinary && hasBinary(packets)) { return encodePayloadAsBinary(packets, callback); }