From 3b8288e302c938ea4728314ebe43e6110d532c3f Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Fri, 3 May 2024 16:27:30 +0500 Subject: [PATCH] Handle serializer on message receive --- lib/src/session.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/session.dart b/lib/src/session.dart index 384f536..3faf614 100644 --- a/lib/src/session.dart +++ b/lib/src/session.dart @@ -5,6 +5,7 @@ import "package:wamp/src/helpers.dart"; import "package:wamp/src/types.dart"; import "package:wampproto/idgen.dart"; import "package:wampproto/messages.dart" as msg; +import "package:wampproto/serializers.dart"; import "package:wampproto/session.dart"; class Session { @@ -13,7 +14,12 @@ class Session { Future.microtask(() async { while (true) { var message = await _baseSession.receive(); - var decodedMessage = Uint8List.fromList((message as String).codeUnits); + Uint8List decodedMessage; + if (_baseSession.serializer == JSONSerializer()) { + decodedMessage = Uint8List.fromList((message as String).codeUnits); + } else { + decodedMessage = message as Uint8List; + } _processIncomingMessage(_wampSession.receive(decodedMessage)); } });