Connectivity

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Classes for monitoring connectivity events at the transport and link levels. Transport events notify about connections being opened or closed to remote zenoh nodes. Link events notify about individual data links being added or removed within a transport.

Current transports and links can be retrieved via Session::get_transports() and Session::get_links().

Transport events listeners are declared via Session::declare_transport_events_listener(). Link events listeners are declared via Session::declare_link_events_listener().

Both listener types accept an options struct with a history field. When history is set to true, the listener will immediately receive events for transports or links that were already established before the listener was declared, in addition to future events.

Transport

class Transport : public zenoh::Owned<::z_owned_transport_t>

Represents a connection to a remote zenoh node.

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Methods

inline Id get_zid() const

Get the Zenoh ID of the remote node.

Returns:

Id of the remote node.

inline WhatAmI get_whatami() const

Get the type of the remote node.

Returns:

zenoh::WhatAmI of the remote node.

inline bool is_qos() const

Check if the transport supports QoS.

Returns:

true if QoS is supported, false otherwise.

inline bool is_multicast() const

Check if the transport is multicast.

Returns:

true if the transport is multicast, false otherwise.

inline bool is_shm() const

Check if the transport supports shared memory.

Returns:

true if shared memory is supported, false otherwise.

inline Transport(const Transport &other)

Copy constructor.

Transport(Transport &&other) = default

Move constructor.

Operators

inline Transport &operator=(const Transport &other)

Assignment operator.

Transport &operator=(Transport &&other) = default

Move assignment operator.

class TransportEvent : public zenoh::Owned<::z_owned_transport_event_t>

Represents a transport connectivity event (transport opened or closed).

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Methods

inline SampleKind get_kind() const

Get the kind of this event.

Returns:

SampleKind::Z_SAMPLE_KIND_PUT for transport opened, SampleKind::Z_SAMPLE_KIND_DELETE for transport closed.

inline const Transport &get_transport() const

Get the transport associated with this event.

Returns:

reference to the Transport.

template<class Handler>
class TransportEventsListener : public zenoh::detail::TransportEventsListenerBase

A Zenoh transport events listener.

Constructed by Session::declare_transport_events_listener method.

Template Parameters:

Handler – streaming handler exposing data. If void, no handler access is provided and instead data is being processed inside the callback.

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Methods

inline Handler undeclare(ZResult *err = nullptr) &&

Undeclare transport events listener, and return its handler.

Parameters:

err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.

inline const Handler &handler() const

Return the handler to transport events data stream.

Constructors

inline TransportEventsListener(TransportEventsListener<void> &&l, Handler handler)

Construct stream transport events listener from callback listener and handler.

Parameters:
  • l – callback transport events listener, that should expose data to the handler in its callback.

  • handler – handler to access data exposed by l.