Skip to content

Commit

Permalink
Merge pull request #567 from elfenpiff/iox2-566-fix-event-based-comm-…
Browse files Browse the repository at this point in the history
…cxx-example

[#566] Fix event based comm cxx example
  • Loading branch information
elfenpiff authored Dec 24, 2024
2 parents 3526a25 + 97aff93 commit f4931fd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 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 @@ -45,8 +47,12 @@ class CustomSubscriber : public iox2::FileDescriptorBased {

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("");
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 f4931fd

Please sign in to comment.