declare static method

AdvancedPublisher declare(
  1. Pointer<Void> loanedSession,
  2. Pointer<Void> loanedKe,
  3. String keyExpr, {
  4. bool enableCache = false,
  5. int cacheMaxSamples = 0,
  6. bool publisherDetection = false,
  7. bool sampleMissDetection = false,
  8. HeartbeatMode heartbeatMode = HeartbeatMode.none,
  9. int heartbeatPeriodMs = 0,
})

Creates an advanced publisher on the given session and key expression.

This is called internally by Session.declareAdvancedPublisher.

Implementation

static AdvancedPublisher declare(
  Pointer<Void> loanedSession,
  Pointer<Void> loanedKe,
  String keyExpr, {
  bool enableCache = false,
  int cacheMaxSamples = 0,
  bool publisherDetection = false,
  bool sampleMissDetection = false,
  HeartbeatMode heartbeatMode = HeartbeatMode.none,
  int heartbeatPeriodMs = 0,
}) {
  final size = bindings.zd_advanced_publisher_sizeof();
  final Pointer<Void> ptr = calloc.allocate(size);

  final rc = bindings.zd_declare_advanced_publisher(
    loanedSession.cast(),
    ptr.cast(),
    loanedKe.cast(),
    enableCache,
    cacheMaxSamples,
    publisherDetection,
    sampleMissDetection,
    heartbeatMode.value,
    heartbeatPeriodMs,
  );

  if (rc != 0) {
    calloc.free(ptr);
    throw ZenohException('Failed to declare advanced publisher', rc);
  }

  return AdvancedPublisher._(ptr, keyExpr);
}