1
- // SPDX-FileCopyrightText: 2024 Contributors to the Eclipse Foundation
1
+ // SPDX-FileCopyrightText: 2025 Contributors to the Eclipse Foundation
2
2
//
3
3
// See the NOTICE file(s) distributed with this work for additional
4
4
// information regarding copyright ownership.
23
23
// / The uEntity (type) identifier of the uSubscription service.
24
24
constexpr uint32_t USUBSCRIPTION_TYPE_ID = 0x00000000 ;
25
25
// / The (latest) major version of the uSubscription service.
26
- constexpr uint8_t USUBSCRIPTION_VERSION_MAJOR = 0x03 ;
26
+ constexpr uint8_t UE_VERSION_MAJOR = 0x03 ;
27
27
// / The resource identifier of uSubscription's _subscribe_ operation.
28
28
constexpr uint16_t RESOURCE_ID_SUBSCRIBE = 0x0001 ;
29
29
// / The resource identifier of uSubscription's _unsubscribe_ operation.
30
30
constexpr uint16_t RESOURCE_ID_UNSUBSCRIBE = 0x0002 ;
31
31
// / The resource identifier of uSubscription's _fetch subscriptions_ operation.
32
32
constexpr uint16_t RESOURCE_ID_FETCH_SUBSCRIPTIONS = 0x0003 ;
33
- // / The resource identifier of uSubscription's _register for notifications_ operation.
33
+ // / The resource identifier of uSubscription's _register for notifications_
34
+ // / operation.
34
35
constexpr uint16_t RESOURCE_ID_REGISTER_FOR_NOTIFICATIONS = 0x0006 ;
35
- // / The resource identifier of uSubscription's _unregister for notifications_ operation.
36
+ // / The resource identifier of uSubscription's _unregister for notifications_
37
+ // / operation.
36
38
constexpr uint16_t RESOURCE_ID_UNREGISTER_FOR_NOTIFICATIONS = 0x0007 ;
37
39
// / The resource identifier of uSubscription's _fetch subscribers_ operation.
38
40
constexpr uint16_t RESOURCE_ID_FETCH_SUBSCRIBERS = 0x0008 ;
39
- // TODO(lennart) see default_call_options() for the request in Rust
40
- constexpr auto USUBSCRIPTION_REQUEST_TTL =
41
- std::chrono::milliseconds (0x0800 ); // TODO(lennart) change time
41
+
42
+ constexpr auto USUBSCRIPTION_REQUEST_TTL = std::chrono::milliseconds(5000 );
42
43
43
44
namespace uprotocol ::core::usubscription::v3 {
44
45
using v3::SubscriptionRequest;
45
46
using v3::UnsubscribeRequest;
46
47
47
- // / @brief Interface for uEntities to create subscriptions.
48
- // /
49
- // / Like all L3 client APIs, the RpcClientUSubscription is a wrapper on top of
50
- // / the L2 Communication APIs and USubscription service.
48
+ // / @brief Client which implements the USubscription interface
51
49
struct RpcClientUSubscription : USubscription {
52
50
using RpcClientUSubscriptionOrStatus =
53
51
utils::Expected<std::unique_ptr<RpcClientUSubscription>, v1::UStatus>;
@@ -57,54 +55,72 @@ struct RpcClientUSubscription : USubscription {
57
55
template <typename Response>
58
56
Response invokeResponse (communication::RpcClient rpc_client);
59
57
60
- // / @brief Subscribe to the topic
58
+ // / @brief Subscribes from a given topic
61
59
// /
60
+ // / @param subscription_request The request object containing the topic to
61
+ // / subscribe to
62
+ // / @return Returns a SubscriptionResponse on success and a UStatus else
62
63
utils::Expected<SubscriptionResponse, v1::UStatus> subscribe (
63
64
const SubscriptionRequest& subscription_request) override ;
64
65
65
- // / @brief Unsubscribe from the topic
66
+ // / @brief Unsubscribes from a given topic
66
67
// /
68
+ // / @param unsubscribe_request The request object containing the topic to
69
+ // / unsubscribe from
70
+ // / @return Returns an UnsubscribeResponse on success and a UStatus else
67
71
utils::Expected<UnsubscribeResponse, v1::UStatus> unsubscribe (
68
72
const UnsubscribeRequest& unsubscribe_request) override ;
69
-
70
- // / @brief Fetch all subscriptions either by topic or subscriber
71
- // /
72
- utils::Expected<FetchSubscriptionsResponse, v1::UStatus> fetch_subscriptions (
73
- const FetchSubscriptionsRequest& fetch_subscribers) override ;
74
73
75
- // / @brief Fetch all subscribers
74
+ // / @brief Fetches the list of topics the client is subscribed to
76
75
// /
76
+ // / @param fetch_subscriptions_request The request object
77
+ // / @return Returns a FetchSubscriptionsResponse on success and a UStatus
78
+ // / else
79
+ utils::Expected<FetchSubscriptionsResponse, v1::UStatus>
80
+ fetch_subscriptions (
81
+ const FetchSubscriptionsRequest& fetch_subscriptions_request) override ;
82
+
83
+ // / @brief Fetches the list of subscribers for a given topic
84
+ // /
85
+ // / @param fetch_subscribers_request The request object containing the topic
86
+ // / for which the subscribers are to be fetched
87
+ // / @return Returns a FetchSubscribersResponse on success and a UStatus else
77
88
utils::Expected<FetchSubscribersResponse, v1::UStatus> fetch_subscribers (
78
- const FetchSubscribersRequest& fetch_subscribers ) override ;
89
+ const FetchSubscribersRequest& fetch_subscribers_request ) override ;
79
90
80
- // / @brief Register for notifications
91
+ // / @brief Registers to receive notifications
81
92
// /
82
- utils::Expected<NotificationsResponse, v1::UStatus> register_for_notifications (const
83
- NotificationsRequest& register_notifications_request) override ;
84
-
85
- // / @brief Unregister for notifications
93
+ // / @param register_notifications_request The request object containing
94
+ // / the details to register for notifications
95
+ // / @return Returns a NotificationResponse on success and a UStatus else
96
+ utils::Expected<NotificationsResponse, v1::UStatus>
97
+ register_for_notifications (
98
+ const NotificationsRequest& register_notifications_request) override ;
99
+
100
+ // / @brief Unregisters from receiving notifications.
86
101
// /
87
- utils::Expected<NotificationsResponse, v1::UStatus> unregister_for_notifications (const
88
- NotificationsRequest& unregister_notifications_request) override ;
102
+ // / @param unregister_notifications_request The request object containing
103
+ // / the details needed to stop receiving notifications.
104
+ // / @return Returns a NotificationResponse on success and a UStatus else
105
+ utils::Expected<NotificationsResponse, v1::UStatus>
106
+ unregister_for_notifications (
107
+ const NotificationsRequest& unregister_notifications_request) override ;
89
108
90
109
// / @brief Constructor
91
110
// /
92
- // / @param transport Transport to register with.
111
+ // / @param transport Transport used to send messages
93
112
explicit RpcClientUSubscription (
94
113
std::shared_ptr<transport::UTransport> transport)
95
114
: transport_(std::move(transport)) {}
96
115
97
- // / @brief Destructor
98
116
~RpcClientUSubscription () override = default ;
99
117
100
118
private:
101
- // Transport
102
119
std::shared_ptr<transport::UTransport> transport_;
103
120
104
- // URI info about the uSubscription service
105
121
USubscriptionUUriBuilder uuri_builder_;
106
122
};
107
123
108
124
} // namespace uprotocol::core::usubscription::v3
109
125
110
- #endif // UP_CPP_CLIENT_USUBSCRIPTION_V3_RPCCLIENTUSUBSCRIPTION_H
126
+ #endif // UP_CPP_CLIENT_USUBSCRIPTION_V3_RPCCLIENTUSUBSCRIPTION_H
0 commit comments