startSendingData method

  1. @override
void startSendingData(
  1. int currentTime,
  2. int waitingAckId
)
override

Implementation

@override
void startSendingData(int currentTime, int waitingAckId) {
  _pendingSending = false;

  if (waitingAckId != -1) {
    _waitingAckCount++;
    _lastWatingAckId = waitingAckId;
  }

  if (requester.connection == null) {
    return;
  }
  var toAdd = <Map>[];

  var processingPaths = _changedPaths;
  _changedPaths = HashSet<String>();
  for (var path in processingPaths) {
    if (subscriptions.containsKey(path)) {
      var sub = subscriptions[path]!;
      Map m = <String, dynamic>{'path': path, 'sid': sub.sid};
      if (sub.currentQos > 0) {
        m['qos'] = sub.currentQos;
      }
      toAdd.add(m);
    }
  }
  if (toAdd.isNotEmpty) {
    requester._sendRequest(<String, dynamic>{
      'method': 'subscribe',
      'paths': toAdd,
    }, null);
  }
  if (toRemove.isNotEmpty) {
    var removeSids = <int>[];
    toRemove.forEach((int sid, ReqSubscribeController sub) {
      if (sub.callbacks.isEmpty) {
        removeSids.add(sid);
        subscriptions.remove(sub.node.remotePath);
        subscriptionIds.remove(sub.sid);
        sub._destroy();
      }
    });
    requester._sendRequest(<String, dynamic>{
      'method': 'unsubscribe',
      'sids': removeSids,
    }, null);
    toRemove.clear();
  }
}