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 WhatAmI get_whatami() const
Get the type of the remote node.
- Returns:
zenoh::WhatAmIof the remote node.
-
inline bool is_qos() const
Check if the transport supports QoS.
- Returns:
trueif QoS is supported,falseotherwise.
-
inline bool is_multicast() const
Check if the transport is multicast.
- Returns:
trueif the transport is multicast,falseotherwise.
-
inline bool is_shm() const
Check if the transport supports shared memory.
- Returns:
trueif shared memory is supported,falseotherwise.
-
inline WhatAmI get_whatami() const
-
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_PUTfor transport opened,SampleKind::Z_SAMPLE_KIND_DELETEfor transport closed.
-
inline SampleKind get_kind() const
-
template<class Handler>
class TransportEventsListener : public zenoh::detail::TransportEventsListenerBase A Zenoh transport events listener.
Constructed by
Session::declare_transport_events_listenermethod.- 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.
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.
Link
-
class Link : public zenoh::Owned<::z_owned_link_t>
Represents a data link to a remote zenoh node over a specific protocol.
Warning
This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Methods
-
inline std::string get_src() const
Get the source address of the link.
- Returns:
source address string.
-
inline std::string get_dst() const
Get the destination address of the link.
- Returns:
destination address string.
-
inline std::optional<std::string> get_group() const
Get the group of the link.
- Returns:
group string or
std::nulloptif not available.
-
inline std::optional<std::string> get_auth_identifier() const
Get the authentication identifier of the link.
- Returns:
authentication identifier string or
std::nulloptif not available.
-
inline uint16_t get_mtu() const
Get the MTU (Maximum Transmission Unit) of the link.
- Returns:
MTU value.
-
inline bool is_streamed() const
Check if the link is streamed.
- Returns:
trueif the link is streamed,falseotherwise.
-
inline std::vector<std::string> get_interfaces() const
Get the network interfaces associated with this link.
- Returns:
vector of interface names.
-
inline std::optional<std::pair<uint8_t, uint8_t>> get_priorities() const
Get the priority range supported by this link.
- Returns:
pair of (min, max) priority values or
std::nulloptif not available.
-
inline std::optional<Reliability> get_reliability() const
Get the reliability of this link.
- Returns:
reliability value or
std::nulloptif not available.
-
inline std::string get_src() const
-
class LinkEvent : public zenoh::Owned<::z_owned_link_event_t>
Represents a link connectivity event (link added or removed).
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_PUTfor link added,SampleKind::Z_SAMPLE_KIND_DELETEfor link removed.
-
inline SampleKind get_kind() const
-
template<class Handler>
class LinkEventsListener : public zenoh::detail::LinkEventsListenerBase A Zenoh link events listener.
Constructed by
Session::declare_link_events_listenermethod.- 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 link 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.
Constructors
-
inline LinkEventsListener(LinkEventsListener<void> &&l, Handler handler)
Construct stream link events listener from callback listener and handler.
- Parameters:
l – callback link events listener, that should expose data to the handler in its callback.
handler – handler to access data exposed by
l.