resume method

void resume()

Resume currently paused subscription.

If subscription is not paused, then this method is a no-op.

Implementation

void resume() {
  if (isCancelled) {
    _logger
        .warning('Tried resuming a subscription that is already cancelled.');
    return;
  }

  if (!isPaused) {
    _logger.silly('Resuming a subscription that is not paused is a no-op.');
    return;
  }

  _logger.verbose('Resuming subscription.');

  _envelopeSubscription = _manager.envelopes.where((envelope) {
    // If message was sent to one of our channels.
    if (channels.contains(envelope.channel)) {
      return true;
    }

    // If message was sent to one of our channel patterns.
    if (channels.contains(envelope.subscriptionPattern)) {
      return true;
    }

    // If message was sent to one of our channel groups.
    if (channelGroups.contains(envelope.subscriptionPattern)) {
      return true;
    }

    // If presence is enabled...

    if (withPresence) {
      // ...and message was sent to one of our presence channels.
      if (presenceChannels.contains(envelope.channel)) {
        return true;
      }

      // ...and message was sent to one of our presence channel groups.
      if (presenceChannelGroups.contains(envelope.subscriptionPattern)) {
        return true;
      }
    }

    // Otherwise this is not our message.
    return false;
  }).listen(
    _envelopesController.add,
    onError: (error) {
      _envelopesController.addError(error);
    },
  );
}