Subscriber class
A zenoh subscriber that receives samples on a key expression.
Wraps z_owned_subscriber_t. Samples are delivered asynchronously
via a Stream. Call close when done to undeclare the subscriber
and release native resources.
This object holds a native handle, so it cannot cross an isolate
boundary: a copy would share this one's native address while carrying
its own fresh disposal flag, and the second release would be a
use-after-free. Sending it throws ArgumentError naming the class.
⛔ No NativeFinalizer is attached to this class, deliberately: the
resource a user holds is the STREAM, and the stream does not reference this
wrapper — so it is collected while still in use. Measured: 3 samples
delivered becomes 0.
Releasing it explicitly is therefore the only thing that reclaims it.
- Implemented types
Constructors
-
Subscriber.declare(Pointer<
Void> loanedSession, Pointer<Void> loanedKe, {required String keyExpr, Locality? allowedOrigin, bool retainPayload = false}) -
Creates a subscriber on the given session and key expression.
factory
-
Subscriber.fromParts(Pointer<
Void> ptr, SampleChannel channel, String keyExpr) -
Creates a Subscriber from a pre-allocated native handle and a
SampleChannel.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyExpr → String
-
The key expression this subscriber is declared on.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
Sample> -
A stream of Samples received by this subscriber.
no setter
Methods
-
close(
) → void - Undeclares the subscriber and releases native resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
createSampleChannel(
{bool retainPayload = false}) → SampleChannel - Sets up the ReceivePort / StreamController pair that parses incoming NativePort sample messages into Sample objects.