9#include "open62541pp/config.hpp"
21#ifdef UA_ENABLE_SUBSCRIPTIONS
89 Client& connection, uint32_t subscriptionId, std::unique_ptr<SubscriptionContext>&& context
111 bool publishingEnabled,
116#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
123template <
typename CompletionToken>
129 CompletionToken&& token
132 connection, std::move(statusChangeCallback), std::move(deleteCallback)
137 throwIfBad(UA_Client_Subscriptions_create_async(
138 opcua::detail::getHandle(connection),
141 detail::SubscriptionContext::statusChangeCallbackNative,
142 detail::SubscriptionContext::deleteCallbackNative,
150 if (detail::getServiceResult(response).isGood()) {
151 detail::storeSubscriptionContext(
152 connection, response.getSubscriptionId(), std::move(context)
156 std::forward<CompletionToken>(token)
162template <
typename CompletionToken>
166 bool publishingEnabled,
169 CompletionToken&& token
171 const auto request = detail::createCreateSubscriptionRequest(parameters, publishingEnabled);
174 asWrapper<CreateSubscriptionRequest>(request),
175 std::move(statusChangeCallback),
176 std::move(deleteCallback),
177 std::forward<CompletionToken>(token)
203 const auto request = detail::createModifySubscriptionRequest(subscriptionId, parameters);
207#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
213template <
typename CompletionToken>
224 std::forward<CompletionToken>(token)
229template <
typename CompletionToken>
232 uint32_t subscriptionId,
234 CompletionToken&& token
236 const auto request = detail::createModifySubscriptionRequest(subscriptionId, parameters);
239 asWrapper<ModifySubscriptionRequest>(request),
240 std::forward<CompletionToken>(token)
269template <
typename CompletionToken>
273 return detail::sendRequestAsync<SetPublishingModeRequest, SetPublishingModeResponse>(
274 connection, request, std::forward<CompletionToken>(token)
285 Client& connection, uint32_t subscriptionId,
bool publishing
287 const auto request = detail::createSetPublishingModeRequest(publishing, {&subscriptionId, 1});
288 return detail::getSingleStatus(
298template <
typename CompletionToken>
300 Client& connection, uint32_t subscriptionId,
bool publishing, CompletionToken&& token
302 const auto request = detail::createSetPublishingModeRequest(publishing, {&subscriptionId, 1});
305 asWrapper<SetPublishingModeRequest>(request),
307 detail::getSingleStatus<UA_SetPublishingModeResponse>,
308 std::forward<CompletionToken>(token)
330#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
336template <
typename CompletionToken>
347 std::forward<CompletionToken>(token)
358 const auto request = detail::createDeleteSubscriptionsRequest(subscriptionId);
359 return detail::getSingleStatus(
364#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
370template <
typename CompletionToken>
372 const auto request = detail::createDeleteSubscriptionsRequest(subscriptionId);
375 asWrapper<DeleteSubscriptionsRequest>(request),
377 detail::getSingleStatus<UA_DeleteSubscriptionsResponse>,
378 std::forward<CompletionToken>(token)
UA_CreateSubscriptionRequest wrapper class.
UA_CreateSubscriptionResponse wrapper class.
UA_DeleteSubscriptionsRequest wrapper class.
UA_DeleteSubscriptionsResponse wrapper class.
UA_ModifySubscriptionRequest wrapper class.
UA_ModifySubscriptionResponse wrapper class.
UA_SetPublishingModeRequest wrapper class.
UA_SetPublishingModeResponse wrapper class.
UA_StatusChangeNotification wrapper class.
UA_StatusCode wrapper class.
void(* UA_ClientAsyncServiceCallback)(UA_Client *client, void *userdata, UA_UInt32 requestId, void *response)
UA_StatusCode UA_Client_Subscriptions_delete_async(UA_Client *client, const UA_DeleteSubscriptionsRequest request, UA_ClientAsyncServiceCallback callback, void *userdata, UA_UInt32 *requestId)
UA_StatusCode UA_Client_Subscriptions_modify_async(UA_Client *client, const UA_ModifySubscriptionRequest request, UA_ClientAsyncServiceCallback callback, void *userdata, UA_UInt32 *requestId)
auto createSubscriptionAsync(Client &connection, const CreateSubscriptionRequest &request, StatusChangeNotificationCallback statusChangeCallback, DeleteSubscriptionCallback deleteCallback, CompletionToken &&token)
Create a subscription.
std::function< void(uint32_t subId)> DeleteSubscriptionCallback
Subscription deletion callback.
CreateSubscriptionResponse createSubscription(Client &connection, const CreateSubscriptionRequest &request, StatusChangeNotificationCallback statusChangeCallback, DeleteSubscriptionCallback deleteCallback)
Create a subscription.
std::function< void(uint32_t subId, StatusChangeNotification ¬ification)> StatusChangeNotificationCallback
Subscription status change notification callback.
StatusCode deleteSubscription(Client &connection, uint32_t subscriptionId) noexcept
Delete a single subscription.
DeleteSubscriptionsResponse deleteSubscriptions(Client &connection, const DeleteSubscriptionsRequest &request) noexcept
Delete subscriptions.
auto deleteSubscriptionsAsync(Client &connection, const DeleteSubscriptionsRequest &request, CompletionToken &&token)
Delete subscriptions.
auto deleteSubscriptionAsync(Client &connection, uint32_t subscriptionId, CompletionToken &&token)
Delete a single subscription.
ModifySubscriptionResponse modifySubscription(Client &connection, const ModifySubscriptionRequest &request) noexcept
Modify a subscription.
auto modifySubscriptionAsync(Client &connection, const ModifySubscriptionRequest &request, CompletionToken &&token)
Modify a subscription.
SetPublishingModeResponse setPublishingMode(Client &connection, const SetPublishingModeRequest &request) noexcept
Enable/disable publishing of notification messages of subscriptions.
auto setPublishingModeAsync(Client &connection, const SetPublishingModeRequest &request, CompletionToken &&token)
Enable/disable publishing of notification messages of subscriptions.
constexpr NativeType * asNative(WrapperType *wrapper) noexcept
Cast Wrapper object pointers to native object pointers.
UA_Client * getHandle(Client &client) noexcept
void storeSubscriptionContext(Client &connection, uint32_t subscriptionId, std::unique_ptr< SubscriptionContext > &&context)
std::unique_ptr< SubscriptionContext > createSubscriptionContext(Client &connection, StatusChangeNotificationCallback &&statusChangeCallback, DeleteSubscriptionCallback &&deleteCallback)
OPC UA services as free functions.
constexpr void throwIfBad(UA_StatusCode code)
Check the status code and throw a BadStatus exception if the status code is bad.
Subscription parameters with default values from open62541.
uint8_t priority
Relative priority of the subscription. Notifications with higher priority are sent first.
uint32_t maxKeepAliveCount
Send keep-alive message after defined publishing cycles without notifications.
uint32_t maxNotificationsPerPublish
The maximum number of notifications per publish (0 if unlimited).
uint32_t lifetimeCount
Delete the subscription after defined publishing cycles without sending any notifications.
double publishingInterval
Cyclic interval in milliseconds that the subscription is requested to return notifications.
Adapter to initiate open62541 async client operations with completion tokens.
static auto initiate(Client &client, Initiation &&initiation, CompletionToken &&token)
Initiate open62541 async client operation with user-defined completion token.
Special token to execute a hook function with the const result within the completion handler.