Skip to content

Commit

Permalink
Refactor receive method to wait for incoming messages
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed May 14, 2024
1 parent 2857299 commit 805641d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,13 @@ class ClientSideLocalBaseSession implements IBaseSession {

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

return _incomingMessages.removeFirst();
await _completer.future;
_completer = Completer();
return receive();
}

@override
Expand Down

0 comments on commit 805641d

Please sign in to comment.