Skip to content

Commit

Permalink
Fix ClientSideLocalBaseSession to wait only when incoming messages ar…
Browse files Browse the repository at this point in the history
…e empty
  • Loading branch information
muzzammilshahid committed May 11, 2024
1 parent 77043dd commit e67fe59
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class ClientSideLocalBaseSession implements IBaseSession {
String authrole() => _authrole;

@override
serializer() => _serializer;
Serializer serializer() => _serializer;

@override
Future send(Object data) async {
Expand All @@ -238,8 +238,11 @@ class ClientSideLocalBaseSession implements IBaseSession {

@override
Future<Object> receive() async {
await _completer.future;
_completer = Completer();
if (_incomingMessages.isEmpty) {
await _completer.future;
_completer = Completer();
}

return _incomingMessages.removeFirst();
}

Expand All @@ -258,7 +261,9 @@ class ClientSideLocalBaseSession implements IBaseSession {

Future feed(Object data) async {
_incomingMessages.add(data);
_completer.complete();
if (!_completer.isCompleted) {
_completer.complete();
}
}
}

Expand Down

0 comments on commit e67fe59

Please sign in to comment.