declareSubscriber method
Declares a subscriber on the given keyExpr.
Returns a Subscriber whose Subscriber.stream delivers Samples. Call Subscriber.close when done to undeclare and release resources.
Throws ZenohException if the key expression is invalid. Throws StateError if the session has been closed.
Implementation
Subscriber declareSubscriber(String keyExpr) {
_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 Subscriber.declare(loanedSession, loanedKe);
} finally {
ke.dispose();
}
}