open62541pp 0.17.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
client_context.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <atomic>
5#include <cstdint>
6#include <functional>
7#include <memory>
8#include <utility> // pair
9#include <vector>
10
11#include "open62541pp/config.hpp"
15#include "open62541pp/detail/open62541/client.h" // UA_SessionState, UA_SecureChannelState
18#include "open62541pp/ua/types.hpp" // IntegerId
19
20namespace opcua::detail {
21
22enum class ClientState {
23 Disconnected,
24 Connected,
25 SessionActivated,
26 SessionClosed,
27};
28inline constexpr size_t clientStateCount = 4;
29
30/**
31 * Internal storage for Client class.
32 */
33struct ClientContext {
34 ExceptionCatcher exceptionCatcher;
35 std::atomic<bool> running{false};
36
37 std::vector<DataType> dataTypes;
38 std::unique_ptr<UA_DataTypeArray> dataTypeArray;
39
40#if UAPP_OPEN62541_VER_LE(1, 0)
41 UA_ClientState lastClientState{};
42#else
43 UA_SessionState lastSessionState{};
44 UA_SecureChannelState lastChannelState{};
45#endif
46 std::array<std::function<void()>, clientStateCount> stateCallbacks;
47 std::function<void()> inactivityCallback;
48
49#ifdef UA_ENABLE_SUBSCRIPTIONS
50 using SubId = IntegerId;
51 using MonId = IntegerId;
52 using SubMonId = std::pair<SubId, MonId>;
53 ContextMap<SubId, services::detail::SubscriptionContext> subscriptions;
54 ContextMap<SubMonId, services::detail::MonitoredItemContext> monitoredItems;
55 std::function<void(IntegerId)> subscriptionInactivityCallback;
56#endif
57};
58
59} // namespace opcua::detail
UA_SessionState
UA_SecureChannelState
uint32_t IntegerId
IntegerId.
Definition types.hpp:123