Skip to content

Commit

Permalink
[#566] Fix event based comm cxx example
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Dec 24, 2024
1 parent 3526a25 commit 7c046c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class CustomPublisher : public iox2::FileDescriptorBased {
.expect("");
}

static auto create(iox2::Node<iox2::ServiceType::Ipc>& node, const iox2::ServiceName& service_name)
-> CustomPublisher {
static auto create(iox2::Node<iox2::ServiceType::Ipc>& node,
const iox2::ServiceName& service_name) -> CustomPublisher {
auto pubsub_service = node.service_builder(service_name)
.publish_subscribe<TransmissionData>()
.history_size(HISTORY_SIZE)
Expand Down
14 changes: 10 additions & 4 deletions examples/cxx/event_based_communication/src/custom_subscriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "pubsub_event.hpp"
#include "transmission_data.hpp"

constexpr uint64_t HISTORY_SIZE = 20;

// High-level subscriber class that contains besides a subscriber also a notifier
// and a listener. The notifier is used to send events like
// `PubSubEvent::ReceivedSample` or to notify the publisher that a new subscriber
Expand All @@ -43,10 +45,14 @@ class CustomSubscriber : public iox2::FileDescriptorBased {
auto operator=(const CustomSubscriber&) -> CustomSubscriber& = delete;
auto operator=(CustomSubscriber&&) -> CustomSubscriber& = default;

static auto create(iox2::Node<iox2::ServiceType::Ipc>& node, const iox2::ServiceName& service_name)
-> CustomSubscriber {
auto pubsub_service =
node.service_builder(service_name).publish_subscribe<TransmissionData>().open_or_create().expect("");
static auto create(iox2::Node<iox2::ServiceType::Ipc>& node,
const iox2::ServiceName& service_name) -> CustomSubscriber {
auto pubsub_service = node.service_builder(service_name)
.publish_subscribe<TransmissionData>()
.history_size(HISTORY_SIZE)
.subscriber_max_buffer_size(HISTORY_SIZE)
.open_or_create()
.expect("");
auto event_service = node.service_builder(service_name).event().open_or_create().expect("");

auto listener = event_service.listener_builder().create().expect("");
Expand Down

0 comments on commit 7c046c9

Please sign in to comment.