leave method

Future<CtrlMessage> leave(
  1. bool unsubscribe
)

Leave the topic, optionally unsubscribe. Leaving the topic means the topic will stop receiving updates from the server. Unsubscribing will terminate user's relationship with the topic.

Wrapper for Tinode.leave

Implementation

Future<CtrlMessage> leave(bool unsubscribe) async {
  if (!isSubscribed && !unsubscribe) {
    return Future.error(Exception('Cannot publish on inactive topic'));
  }

  var ctrl = await _tinodeService.leave(name ?? '', unsubscribe);
  resetSubscription();
  if (unsubscribe) {
    _cacheManager.delete('topic', name ?? '');
    _gone();
  }
  if (ctrl is CtrlMessage) return ctrl;
  return CtrlMessage.fromMessage(ctrl);
}