declareAdvancedSubscriber method

AdvancedSubscriber declareAdvancedSubscriber(
  1. String keyExpr, {
  2. AdvancedSubscriberOptions options = const AdvancedSubscriberOptions(),
})

Declares an advanced subscriber on the given keyExpr.

Returns an AdvancedSubscriber with optional history recovery, late publisher detection, sample recovery, and miss detection capabilities. Call AdvancedSubscriber.close when done.

Throws ZenohException if the key expression is invalid. Throws StateError if the session has been closed.

Implementation

AdvancedSubscriber declareAdvancedSubscriber(
  String keyExpr, {
  AdvancedSubscriberOptions options = const AdvancedSubscriberOptions(),
}) {
  _ensureOpen();
  final ke = KeyExpr(keyExpr);
  try {
    final loanedSession =
        bindings.zd_session_loan(_ptr.cast()) as Pointer<Void>;
    final loanedKe =
        bindings.zd_view_keyexpr_loan(ke.nativePtr.cast()) as Pointer<Void>;
    return AdvancedSubscriber.declare(
      loanedSession,
      loanedKe,
      options: options,
    );
  } finally {
    ke.dispose();
  }
}