receive method

Receives messages from the server.

Returns a Stream of LiveServerResponse objects representing the messages received from the server. The stream will stops once the server sends turn complete message.

Implementation

Stream<LiveServerResponse> receive() async* {
  _checkWsStatus();

  await for (final result in _messageController.stream) {
    yield result;
    if (result case LiveServerContent(turnComplete: true)) {
      break; // Exit the loop when the turn is complete
    }
  }
}