normalizeStreamValue method

  1. @visibleForTesting
Future<void> normalizeStreamValue(
  1. Map data
)

Method normalizeStreamValue Receives a data and check the next steps depending on the data values

Implementation

@visibleForTesting
Future<void> normalizeStreamValue(Map data) async {
  if (data['type'] == 'data' || data['type'] == 'error') {
    controller.add(data);
  } else if (data['type'] == 'connection_ack') {
    await _interceptorExecutor.onConnected(this);
    _numbersOfConnectionAttempts = 0;
    _isConnected = true;
    for (final snap in snapmap.values) {
      sendToWebSocketServer(querySubscription(snap.query));
    }
  } else if (data['type'] == 'connection_error') {
    await Future.delayed(const Duration(seconds: 2));
    await _interceptorExecutor.onTryAgain(this);
    sendToWebSocketServer(jsonEncode(_init));
  }
}