Skip to content

compas_eve.zenoh ¤

Classes¤

ZenohTransport ¤

ZenohTransport(
    config: Config | None = None,
    codec: MessageCodec | None = None,
    *args: Any,
    **kwargs: Any
)

Zenoh transport allows sending and receiving messages using an Apache Zenoh router.

Parameters:

  • config (Config | None, default: None ) –

    The Zenoh configuration to use. If not provided, a default zenoh.Config() will be used.

  • codec (MessageCodec | None, default: None ) –

    The codec to use for encoding and decoding messages. If not provided, defaults to JsonMessageCodec.

Functions¤

advertise ¤
advertise(topic: Topic) -> str

Announce this code will publish messages to the specified topic.

Parameters:

  • topic (Topic) –

    Instance of the topic to advertise.

Returns:

  • str

    Advertising identifier.

close ¤
close() -> None

Close the Zenoh session.

on_ready ¤
on_ready(callback: Callable) -> None

Allows to hook-up to the event triggered when the connection is established.

Parameters:

  • callback (Callable) –

    Function to invoke when the connection is established.

publish ¤
publish(topic: Topic, message: Message) -> None

Publish a message to a topic.

Parameters:

  • topic (Topic) –

    Instance of the topic to publish to.

  • message (Message) –

    Instance of the message to publish.

subscribe ¤
subscribe(topic: Topic, callback: Callable) -> str

Subscribe to a topic.

Parameters:

  • topic (Topic) –

    Instance of the topic to subscribe to.

  • callback (Callable) –

    Callback to invoke whenever a new message arrives.

Returns:

  • str

    Identifier of the subscription.

unsubscribe ¤
unsubscribe(topic: Topic) -> None

Unsubscribe from a topic.

Parameters:

  • topic (Topic) –

    Instance of the topic to unsubscribe from.

unsubscribe_by_id ¤
unsubscribe_by_id(subscribe_id: str) -> None

Unsubscribe from the specified topic based on the subscription id.

Parameters:

  • subscribe_id (str) –

    The subscription identifier.