From 170185ed994f981f4ccda36fe38fe53aaa662ea4 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sat, 3 Feb 2024 23:07:57 +0300 Subject: [PATCH] Enchance listener information, change listener interface. --- ...astRTPSEnum_CustomStringConvertible.swift} | 37 ++++++++-- Sources/FastRTPSSwift/FastRTPSSwift.swift | 52 ++++++++++---- .../FastRTPSWrapper/BridgedParticipant.cpp | 2 +- .../BridgedParticipantListener.cpp | 55 ++++++++++----- .../FastRTPSWrapper/BridgedReaderListener.cpp | 6 +- .../FastRTPSWrapper/BridgedWriterListener.cpp | 6 +- .../{FastRTPSDefs.h => FastDDSVersion.h} | 2 +- .../FastRTPSWrapper/include/FastRTPSDefs.h | 68 ++++++++++++------- .../FastRTPSWrapper/include/FastRTPSWrapper.h | 19 +++--- .../FastRTPSSwiftTests.swift | 15 ++-- 10 files changed, 178 insertions(+), 84 deletions(-) rename Sources/FastRTPSSwift/{FastRTPSNotifications.swift => FastRTPSEnum_CustomStringConvertible.swift} (63%) rename Sources/FastRTPSWrapper/{FastRTPSDefs.h => FastDDSVersion.h} (92%) diff --git a/Sources/FastRTPSSwift/FastRTPSNotifications.swift b/Sources/FastRTPSSwift/FastRTPSEnum_CustomStringConvertible.swift similarity index 63% rename from Sources/FastRTPSSwift/FastRTPSNotifications.swift rename to Sources/FastRTPSSwift/FastRTPSEnum_CustomStringConvertible.swift index 2dc7bbf..89e7bea 100644 --- a/Sources/FastRTPSSwift/FastRTPSNotifications.swift +++ b/Sources/FastRTPSSwift/FastRTPSEnum_CustomStringConvertible.swift @@ -1,12 +1,12 @@ ///// -//// FastRTPSNotifications.swift +//// FastRTPSEnum_CustomStringConvertible.swift /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // import Foundation -extension RTPSNotification: CustomStringConvertible { +extension RTPSStatus: CustomStringConvertible { public var description: String { switch self { case .readerMatchedMatching : return "readerMatchedMatching" @@ -19,22 +19,29 @@ extension RTPSNotification: CustomStringConvertible { } } -extension RTPSReaderWriterNotification: CustomStringConvertible { +extension RTPSReaderStatus: CustomStringConvertible { public var description: String { switch self { case .discoveredReader : return "discoveredReader" case .changedQosReader : return "changedQosReader" case .removedReader : return "removedReader" + case .ignoredReader : return "ignoredReader" + } + } +} + +extension RTPSWriterStatus: CustomStringConvertible { + public var description: String { + switch self { case .discoveredWriter : return "discoveredWriter" case .changedQosWriter : return "changedQosWriter" case .removedWriter : return "removedWriter" - case .ignoredReader : return "ignoredReader" case .ignoredWriter : return "ignoredWriter" } } } -extension RTPSParticipantNotification: CustomStringConvertible { +extension RTPSParticipantStatus: CustomStringConvertible { public var description: String { switch self { case .discoveredParticipant : return "discoveredParticipant" @@ -45,3 +52,23 @@ extension RTPSParticipantNotification: CustomStringConvertible { } } } + +extension Durability: CustomStringConvertible { + public var description: String { + switch self { + case .volatile : return "volatile" + case .transientLocal : return "transientLocal" + case .transient : return "transient" + case .persistent : return "persistent" + } + } +} + +extension Reliability: CustomStringConvertible { + public var description: String { + switch self { + case .bestEffort : return "bestEffort" + case .reliable : return "reliable" + } + } +} diff --git a/Sources/FastRTPSSwift/FastRTPSSwift.swift b/Sources/FastRTPSSwift/FastRTPSSwift.swift index cab0133..33a703c 100644 --- a/Sources/FastRTPSSwift/FastRTPSSwift.swift +++ b/Sources/FastRTPSSwift/FastRTPSSwift.swift @@ -16,25 +16,34 @@ public protocol RTPSListenerDelegate { /// - Parameters: /// - reason: event reason /// - topic: topic name - func RTPSNotification(reason: RTPSNotification, topic: String) + func RTPSNotification(reason: RTPSStatus, topic: String) } /// RTPS Participant listener delegate requrements public protocol RTPSParticipantListenerDelegate { /// Intercepts paricipant discovery events /// - Parameters: - /// - reason: event reaason, see RTPSParticipantNotification + /// - reason: event reaason, see RTPSParticipantStatus /// - participant: participant name /// - unicastLocators: participant unicast locators list /// - properties: participant properties strings - func participantNotification(reason: RTPSParticipantNotification, participant: String, unicastLocators: String, properties: [String:String]) - /// Intercepts readers and writers discovery events + func participantNotification(reason: RTPSParticipantStatus, participant: String, unicastLocators: String, properties: [String:String]) + /// Intercepts reader discovery events /// - Parameters: - /// - reason: event reason, see RTPSReaderWriterNotification enum + /// - reason: event reason, see RTPSReaderStatus enum /// - topic: topic name /// - type: topic data type name /// - remoteLocators: remote locators list - func readerWriterNotificaton(reason: RTPSReaderWriterNotification, topic: String, type: String, remoteLocators: String) + /// - readerProfile: reader qos data + func readerNotificaton(reason: RTPSReaderStatus, topic: String, type: String, remoteLocators: String, readerProfile: RTPSReaderProfile) + /// Intercepts writer discovery events + /// - Parameters: + /// - reason: event reason, see RTPSWriterStatus enum + /// - topic: topic name + /// - type: topic data type name + /// - remoteLocators: remote locators list + /// - writerProfile: writer qos data + func writerNotificaton(reason: RTPSWriterStatus, topic: String, type: String, remoteLocators: String, writerProfile: RTPSWriterProfile) } /// FastRTPSSwift errors enum @@ -93,18 +102,37 @@ open class FastRTPSSwift { participant: String(cString: participantName), unicastLocators: locators, properties: propertiesDict) - }, discoveryReaderWriterCallback: { - (listenerObject, reason, topicName, typeName, remoteLocators) in + }, discoveryReaderCallback: { + (listenerObject, reason, readerInfo) in let mySelf = Unmanaged.fromOpaque(listenerObject).takeUnretainedValue() guard let delegate = mySelf.participantListenerDelegate else { return } - let topic = String(cString: topicName) - let type = String(cString: typeName) + let topic = String(cString: readerInfo.pointee.topic) + let type = String(cString: readerInfo.pointee.ddstype) + var locators = "" + if let remoteLocators = readerInfo.pointee.locators { + locators = String(cString: remoteLocators) + } + let readerProfile = RTPSReaderProfile(keyed: readerInfo.pointee.readerProfile.keyed, + reliability: readerInfo.pointee.readerProfile.reliability, + durability: readerInfo.pointee.readerProfile.durability) + delegate.readerNotificaton(reason: reason, topic: topic, type: type, remoteLocators: locators, readerProfile: readerProfile) + }, discoveryWriterCallback: { + (listenerObject, reason, writerInfo) in + let mySelf = Unmanaged.fromOpaque(listenerObject).takeUnretainedValue() + guard let delegate = mySelf.participantListenerDelegate else { return } + + let topic = String(cString: writerInfo.pointee.topic) + let type = String(cString: writerInfo.pointee.ddstype) var locators = "" - if let remoteLocators = remoteLocators { + if let remoteLocators = writerInfo.pointee.locators { locators = String(cString: remoteLocators) } - delegate.readerWriterNotificaton(reason: reason, topic: topic, type: type, remoteLocators: locators) + let writerProfile = RTPSWriterProfile(keyed: writerInfo.pointee.writerProfile.keyed, + reliability: writerInfo.pointee.writerProfile.reliability, + durability: writerInfo.pointee.writerProfile.durability, + disablePositiveACKs: writerInfo.pointee.writerProfile.disablePositiveACKs) + delegate.writerNotificaton(reason: reason, topic: topic, type: type, remoteLocators: locators, writerProfile: writerProfile) }, listnerObject: Unmanaged.passUnretained(self).toOpaque()) wrapper.setupBridgeContainer(container: container) diff --git a/Sources/FastRTPSWrapper/BridgedParticipant.cpp b/Sources/FastRTPSWrapper/BridgedParticipant.cpp index 47c12ab..f04f7bf 100644 --- a/Sources/FastRTPSWrapper/BridgedParticipant.cpp +++ b/Sources/FastRTPSWrapper/BridgedParticipant.cpp @@ -84,7 +84,7 @@ bool BridgedParticipant::createParticipant(const char* name, participantAttributes.builtin.discovery_config.discoveryProtocol = eprosima::fastrtps::rtps::DiscoveryProtocol::SIMPLE; participantAttributes.setName(name); if (participantProfile != nullptr) { - participantAttributes.builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(participantProfile->leaseDuration_announcementperiod); + participantAttributes.builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(participantProfile->leaseDurationAnnouncementperiod); participantAttributes.builtin.discovery_config.leaseDuration = Duration_t(participantProfile->leaseDuration); switch (participantProfile->participantFilter) { case Disabled: diff --git a/Sources/FastRTPSWrapper/BridgedParticipantListener.cpp b/Sources/FastRTPSWrapper/BridgedParticipantListener.cpp index a261912..3285f06 100644 --- a/Sources/FastRTPSWrapper/BridgedParticipantListener.cpp +++ b/Sources/FastRTPSWrapper/BridgedParticipantListener.cpp @@ -9,7 +9,7 @@ #include #include #include -#include "FastRTPSDefs.h" +#include "FastDDSVersion.h" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -17,24 +17,33 @@ using namespace eprosima::fastrtps::rtps; void BridgedParticipantListener::onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) { (void)participant; - auto topicName = info.info.topicName(); - auto typeName = info.info.typeName(); std::ostringstream stream; + struct ReaderInfo readerInfo; + std::string str; + + readerInfo.locators = nullptr; + readerInfo.topic = info.info.topicName().c_str(); + readerInfo.ddstype = info.info.typeName().c_str(); + readerInfo.readerProfile.reliability = static_cast(info.info.m_qos.m_reliability.kind); + readerInfo.readerProfile.durability = static_cast(info.info.m_qos.m_durability.kind); + readerInfo.readerProfile.keyed = info.info.topicKind() == eprosima::fastrtps::rtps::WITH_KEY; switch(info.status) { case ReaderDiscoveryInfo::DISCOVERED_READER: dumpLocators(info.info.remote_locators().unicast, stream); - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationDiscoveredReader, topicName, typeName, stream.str().c_str()); + str = stream.str(); + readerInfo.locators = str.c_str(); + container.discoveryReaderCallback(container.listnerObject, RTPSReaderStatusDiscoveredReader, &readerInfo); break; case ReaderDiscoveryInfo::CHANGED_QOS_READER: - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationChangedQosReader, topicName, typeName, nullptr); + container.discoveryReaderCallback(container.listnerObject, RTPSReaderStatusChangedQosReader, &readerInfo); break; case ReaderDiscoveryInfo::REMOVED_READER: - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationRemovedReader, topicName, typeName, nullptr); + container.discoveryReaderCallback(container.listnerObject, RTPSReaderStatusRemovedReader, &readerInfo); break; #if FASTDDS_VERSION >= 21000 case ReaderDiscoveryInfo::IGNORED_READER: - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationIgnoredReader, topicName, typeName, nullptr); + container.discoveryReaderCallback(container.listnerObject, RTPSReaderStatusIgnoredReader, &readerInfo); break; #endif } @@ -43,24 +52,34 @@ void BridgedParticipantListener::onReaderDiscovery(RTPSParticipant *participant, void BridgedParticipantListener::onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) { (void)participant; - auto topicName = info.info.topicName(); - auto typeName = info.info.typeName(); std::ostringstream stream; + struct WriterInfo writerInfo; + std::string str; + + writerInfo.locators = nullptr; + writerInfo.topic = info.info.topicName().c_str(); + writerInfo.ddstype = info.info.typeName().c_str(); + writerInfo.writerProfile.reliability = static_cast(info.info.m_qos.m_reliability.kind); + writerInfo.writerProfile.durability = static_cast(info.info.m_qos.m_durability.kind); + writerInfo.writerProfile.keyed = info.info.topicKind() == eprosima::fastrtps::rtps::WITH_KEY; + writerInfo.writerProfile.disablePositiveACKs = info.info.m_qos.m_disablePositiveACKs.enabled; switch(info.status) { case WriterDiscoveryInfo::DISCOVERED_WRITER: dumpLocators(info.info.remote_locators().unicast, stream); - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationDiscoveredWriter, topicName, typeName, stream.str().c_str()); + str = stream.str(); + writerInfo.locators = str.c_str(); + container.discoveryWriterCallback(container.listnerObject, RTPSWriterStatusDiscoveredWriter, &writerInfo); break; case WriterDiscoveryInfo::CHANGED_QOS_WRITER: - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationChangedQosWriter, topicName, typeName, nullptr); + container.discoveryWriterCallback(container.listnerObject, RTPSWriterStatusChangedQosWriter, &writerInfo); break; case WriterDiscoveryInfo::REMOVED_WRITER: - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationRemovedWriter, topicName, typeName, nullptr); + container.discoveryWriterCallback(container.listnerObject, RTPSWriterStatusRemovedWriter, &writerInfo); break; #if FASTDDS_VERSION >= 21000 case WriterDiscoveryInfo::IGNORED_WRITER: - container.discoveryReaderWriterCallback(container.listnerObject, RTPSReaderWriterNotificationIgnoredWriter, topicName, typeName, nullptr); + container.discoveryWriterCallback(container.listnerObject, RTPSWriterStatusIgnoredWriter, &writerInfo); break; #endif } @@ -87,24 +106,24 @@ void BridgedParticipantListener::onParticipantDiscovery(RTPSParticipant *partici } propDict[i] = nullptr; dumpLocators(info.info.default_locators.unicast, stream); - container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantNotificationDiscoveredParticipant, info.info.m_participantName, stream.str().c_str(), propDict); + container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantStatusDiscoveredParticipant, info.info.m_participantName, stream.str().c_str(), propDict); do { free((void *)propDict[i--]); } while (i != 0); delete [] propDict; break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: - container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantNotificationDroppedParticipant, info.info.m_participantName, nullptr, nullptr); + container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantStatusDroppedParticipant, info.info.m_participantName, nullptr, nullptr); break; case ParticipantDiscoveryInfo::REMOVED_PARTICIPANT: - container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantNotificationRemovedParticipant, info.info.m_participantName, nullptr, nullptr); + container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantStatusRemovedParticipant, info.info.m_participantName, nullptr, nullptr); break; case ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT: - container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantNotificationChangedQosParticipant, info.info.m_participantName, nullptr, nullptr); + container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantStatusChangedQosParticipant, info.info.m_participantName, nullptr, nullptr); break; #if FASTDDS_VERSION >= 21000 case ParticipantDiscoveryInfo::IGNORED_PARTICIPANT: - container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantNotificationIgnoredParticipant, info.info.m_participantName, nullptr, nullptr); + container.discoveryParticipantCallback(container.listnerObject, RTPSParticipantStatusIgnoredParticipant, info.info.m_participantName, nullptr, nullptr); break; #endif } diff --git a/Sources/FastRTPSWrapper/BridgedReaderListener.cpp b/Sources/FastRTPSWrapper/BridgedReaderListener.cpp index 8ca08cf..103f674 100644 --- a/Sources/FastRTPSWrapper/BridgedReaderListener.cpp +++ b/Sources/FastRTPSWrapper/BridgedReaderListener.cpp @@ -39,7 +39,7 @@ void BridgedReaderListener::onNewCacheChangeAdded(RTPSReader* reader, const Cach void BridgedReaderListener::on_liveliness_changed(RTPSReader *reader, const LivelinessChangedStatus &status) { - container.readerWriterListenerCallback(container.listnerObject, RTPSNotificationReaderLivelinessLost, topicName.c_str()); + container.readerWriterListenerCallback(container.listnerObject, RTPSStatusReaderLivelinessLost, topicName.c_str()); } void BridgedReaderListener::onReaderMatched(RTPSReader* reader, MatchingInfo& info) @@ -48,11 +48,11 @@ void BridgedReaderListener::onReaderMatched(RTPSReader* reader, MatchingInfo& in { case MATCHED_MATCHING: n_matched++; - container.readerWriterListenerCallback(container.listnerObject, RTPSNotificationReaderMatchedMatching, topicName.c_str()); + container.readerWriterListenerCallback(container.listnerObject, RTPSStatusReaderMatchedMatching, topicName.c_str()); break; case REMOVED_MATCHING: n_matched--; - container.readerWriterListenerCallback(container.listnerObject, RTPSNotificationReaderRemovedMatching, topicName.c_str()); + container.readerWriterListenerCallback(container.listnerObject, RTPSStatusReaderRemovedMatching, topicName.c_str()); break; } } diff --git a/Sources/FastRTPSWrapper/BridgedWriterListener.cpp b/Sources/FastRTPSWrapper/BridgedWriterListener.cpp index c60464b..3d9d02e 100644 --- a/Sources/FastRTPSWrapper/BridgedWriterListener.cpp +++ b/Sources/FastRTPSWrapper/BridgedWriterListener.cpp @@ -22,7 +22,7 @@ BridgedWriterListener::~BridgedWriterListener() void BridgedWriterListener::on_liveliness_lost(RTPSWriter* writer, const LivelinessLostStatus& status) { - container.readerWriterListenerCallback(container.listnerObject, RTPSNotificationWriterLivelinessLost, topicName.c_str()); + container.readerWriterListenerCallback(container.listnerObject, RTPSStatusWriterLivelinessLost, topicName.c_str()); } void BridgedWriterListener::onWriterMatched(RTPSWriter* writer, MatchingInfo& info) @@ -31,11 +31,11 @@ void BridgedWriterListener::onWriterMatched(RTPSWriter* writer, MatchingInfo& in { case MATCHED_MATCHING: n_matched++; - container.readerWriterListenerCallback(container.listnerObject, RTPSNotificationWriterMatchedMatching, topicName.c_str()); + container.readerWriterListenerCallback(container.listnerObject, RTPSStatusWriterMatchedMatching, topicName.c_str()); break; case REMOVED_MATCHING: n_matched--; - container.readerWriterListenerCallback(container.listnerObject, RTPSNotificationWriterRemovedMatching, topicName.c_str()); + container.readerWriterListenerCallback(container.listnerObject, RTPSStatusWriterRemovedMatching, topicName.c_str()); break; } } diff --git a/Sources/FastRTPSWrapper/FastRTPSDefs.h b/Sources/FastRTPSWrapper/FastDDSVersion.h similarity index 92% rename from Sources/FastRTPSWrapper/FastRTPSDefs.h rename to Sources/FastRTPSWrapper/FastDDSVersion.h index 278a809..31e6df4 100644 --- a/Sources/FastRTPSWrapper/FastRTPSDefs.h +++ b/Sources/FastRTPSWrapper/FastDDSVersion.h @@ -1,5 +1,5 @@ // -// FastRTPSDefs.h +// FastDDSVersion.h // // // Created by Dmitriy Borovikov on 22.01.2024. diff --git a/Sources/FastRTPSWrapper/include/FastRTPSDefs.h b/Sources/FastRTPSWrapper/include/FastRTPSDefs.h index 1d15799..0f8a776 100644 --- a/Sources/FastRTPSWrapper/include/FastRTPSDefs.h +++ b/Sources/FastRTPSWrapper/include/FastRTPSDefs.h @@ -31,31 +31,35 @@ # define CF_SWIFT_NAME(_name) #endif -typedef NS_CLOSED_ENUM(uint32_t, RTPSNotification) { - RTPSNotificationReaderMatchedMatching = 0, - RTPSNotificationReaderRemovedMatching, - RTPSNotificationReaderLivelinessLost, - RTPSNotificationWriterMatchedMatching, - RTPSNotificationWriterRemovedMatching, - RTPSNotificationWriterLivelinessLost, +typedef NS_CLOSED_ENUM(uint32_t, RTPSStatus) { + RTPSStatusReaderMatchedMatching = 0, + RTPSStatusReaderRemovedMatching, + RTPSStatusReaderLivelinessLost, + RTPSStatusWriterMatchedMatching, + RTPSStatusWriterRemovedMatching, + RTPSStatusWriterLivelinessLost, }; -typedef NS_CLOSED_ENUM(uint32_t, RTPSReaderWriterNotification) { - RTPSReaderWriterNotificationDiscoveredReader = 0, - RTPSReaderWriterNotificationChangedQosReader, - RTPSReaderWriterNotificationRemovedReader, - RTPSReaderWriterNotificationDiscoveredWriter, - RTPSReaderWriterNotificationChangedQosWriter, - RTPSReaderWriterNotificationRemovedWriter, - RTPSReaderWriterNotificationIgnoredReader, - RTPSReaderWriterNotificationIgnoredWriter, +typedef NS_CLOSED_ENUM(uint32_t, RTPSReaderStatus) { + RTPSReaderStatusDiscoveredReader = 0, + RTPSReaderStatusChangedQosReader, + RTPSReaderStatusRemovedReader, + RTPSReaderStatusIgnoredReader, }; -typedef NS_CLOSED_ENUM(uint32_t, RTPSParticipantNotification) { - RTPSParticipantNotificationDiscoveredParticipant = 0, - RTPSParticipantNotificationChangedQosParticipant, - RTPSParticipantNotificationRemovedParticipant, - RTPSParticipantNotificationDroppedParticipant, - RTPSParticipantNotificationIgnoredParticipant, + +typedef NS_CLOSED_ENUM(uint32_t, RTPSWriterStatus) { + RTPSWriterStatusDiscoveredWriter = 0, + RTPSWriterStatusChangedQosWriter, + RTPSWriterStatusRemovedWriter, + RTPSWriterStatusIgnoredWriter, +}; + +typedef NS_CLOSED_ENUM(uint32_t, RTPSParticipantStatus) { + RTPSParticipantStatusDiscoveredParticipant = 0, + RTPSParticipantStatusChangedQosParticipant, + RTPSParticipantStatusRemovedParticipant, + RTPSParticipantStatusDroppedParticipant, + RTPSParticipantStatusIgnoredParticipant, }; typedef NS_CLOSED_ENUM(uint32_t, FastRTPSLogLevel) { @@ -72,8 +76,8 @@ typedef NS_CLOSED_ENUM(uint32_t, Durability) { }; typedef NS_CLOSED_ENUM(uint32_t, Reliability) { - ReliabilityReliable = 0, - ReliabilityBestEffort, + ReliabilityBestEffort = 1, + ReliabilityReliable = 2, }; typedef NS_CLOSED_ENUM(uint32_t, ParticipantFilter) { @@ -98,9 +102,23 @@ struct RTPSWriterProfile { }; struct RTPSParticipantProfile { - long double leaseDuration_announcementperiod; + long double leaseDurationAnnouncementperiod; long double leaseDuration; ParticipantFilter participantFilter; }; +struct ReaderInfo { + const char *topic; + const char *ddstype; + const char *locators; + struct RTPSReaderProfile readerProfile; +}; + +struct WriterInfo { + const char *topic; + const char *ddstype; + const char *locators; + struct RTPSWriterProfile writerProfile; +}; + #endif /* FastRTPSDefs_h */ diff --git a/Sources/FastRTPSWrapper/include/FastRTPSWrapper.h b/Sources/FastRTPSWrapper/include/FastRTPSWrapper.h index c9ed9ef..6244e26 100644 --- a/Sources/FastRTPSWrapper/include/FastRTPSWrapper.h +++ b/Sources/FastRTPSWrapper/include/FastRTPSWrapper.h @@ -14,20 +14,22 @@ typedef void (*DecoderCallback)(void * _Nonnull payloadDecoder, uint64_t sequence, int payloadSize, uint8_t * _Nonnull payload); typedef void (*ReleaseCallback)(void * _Nonnull payloadDecoder); typedef void (*ReaderWriterListenerCallback)(const void * _Nonnull listnerObject, - RTPSNotification reason, + RTPSStatus reason, const char* _Nonnull topicName); typedef void (*DiscoveryParticipantCallback)(const void * _Nonnull listnerObject, - RTPSParticipantNotification reason, + RTPSParticipantStatus reason, const char * _Nonnull participantName, const char* const _Nullable unicastLocators, const char* const _Nullable properties[_Nullable]); -typedef void (*DiscoveryReaderWriterCallback)(const void * _Nonnull listnerObject, - RTPSReaderWriterNotification reason, - const char* _Nonnull topicName, - const char* _Nonnull typeName, - const char* const _Nullable remoteLocators); +typedef void (*DiscoveryReaderCallback)(const void * _Nonnull listnerObject, + RTPSReaderStatus reason, + const struct ReaderInfo* _Nonnull readerInfo); + +typedef void (*DiscoveryWriterCallback)(const void * _Nonnull listnerObject, + RTPSWriterStatus reason, + const struct WriterInfo* _Nonnull writerInfo); #pragma clang assume_nonnull begin @@ -37,7 +39,8 @@ struct BridgeContainer ReleaseCallback releaseCallback; ReaderWriterListenerCallback readerWriterListenerCallback; DiscoveryParticipantCallback discoveryParticipantCallback; - DiscoveryReaderWriterCallback discoveryReaderWriterCallback; + DiscoveryReaderCallback discoveryReaderCallback; + DiscoveryWriterCallback discoveryWriterCallback; const void *listnerObject; }; diff --git a/Tests/FastRTPSSwiftTests/FastRTPSSwiftTests.swift b/Tests/FastRTPSSwiftTests/FastRTPSSwiftTests.swift index 2843501..6a97df4 100644 --- a/Tests/FastRTPSSwiftTests/FastRTPSSwiftTests.swift +++ b/Tests/FastRTPSSwiftTests/FastRTPSSwiftTests.swift @@ -59,22 +59,21 @@ class FastRTPSSwiftTests: XCTestCase { print("Readers removed") fastRTPSSwift?.removeParticipant() } - - static var allTests = [ - ("testCreateReader", testCreateReader), - ("testCreateMultipleReaders", testCreateMultipleReaders), - ] } extension FastRTPSSwiftTests: RTPSParticipantListenerDelegate { - func participantNotification(reason: RTPSParticipantNotification, participant: String, unicastLocators: String, properties: [String:String]) { + + func participantNotification(reason: RTPSParticipantStatus, participant: String, unicastLocators: String, properties: [String:String]) { print(reason, participant, unicastLocators, properties) } - func readerWriterNotificaton(reason: RTPSReaderWriterNotification, topic: String, type: String, remoteLocators: String) { - print(reason, topic, type, remoteLocators) + func readerNotificaton(reason: RTPSReaderStatus, topic: String, type: String, remoteLocators: String, readerProfile: RTPSReaderProfile) { + print(reason, topic, type, remoteLocators, readerProfile) } + func writerNotificaton(reason: RTPSWriterStatus, topic: String, type: String, remoteLocators: String, writerProfile: RTPSWriterProfile) { + print(reason, topic, type, remoteLocators, writerProfile) + } }