handleCtrlMessage method

void handleCtrlMessage(
  1. CtrlMessage? ctrl
)

Process a packet if the packet type is ctrl

Implementation

void handleCtrlMessage(CtrlMessage? ctrl) {
  if (ctrl == null) {
    return;
  }

  onCtrlMessage.add(ctrl);

  var code = ctrl.code;
  if (ctrl.id != null && ctrl.id != '' && code != null) {
    _futureManager.execFuture(ctrl.id, code, ctrl, ctrl.text);
  }

  if (ctrl.code == 205 && ctrl.text == 'evicted') {
    Topic? topic = _cacheManager.get('topic', ctrl.topic ?? '');
    if (topic != null) {
      topic.resetSubscription();
    }
  }

  if (ctrl.params != null && ctrl.params['what'] == 'data') {
    Topic? topic = _cacheManager.get('topic', ctrl.topic ?? '');
    if (topic != null) {
      var count = ctrl.params['count'];
      topic.allMessagesReceived(count ?? 0);
    }
  }

  if (ctrl.params != null && ctrl.params['what'] == 'sub') {
    Topic? topic = _cacheManager.get('topic', ctrl.topic ?? '');
    if (topic != null) {
      topic.processMetaSub([]);
    }
  }
}