open62541pp 0.18.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 <utility> // pair
8
9#include "open62541pp/config.hpp"
12#include "open62541pp/detail/open62541/client.h" // UA_SessionState, UA_SecureChannelState
15#include "open62541pp/ua/types.hpp" // IntegerId
16
17namespace opcua::detail {
18
19enum class ClientState {
20 Disconnected,
21 Connected,
22 SessionActivated,
23 SessionClosed,
24};
25inline constexpr size_t clientStateCount = 4;
26
27/**
28 * Internal storage for Client class.
29 */
30struct ClientContext {
31 ExceptionCatcher exceptionCatcher;
32 std::atomic<bool> running{false};
33
34#if UAPP_OPEN62541_VER_LE(1, 0)
35 UA_ClientState lastClientState{};
36#else
37 UA_SessionState lastSessionState{};
38 UA_SecureChannelState lastChannelState{};
39#endif
40 std::array<std::function<void()>, clientStateCount> stateCallbacks;
41 std::function<void()> inactivityCallback;
42
43#ifdef UA_ENABLE_SUBSCRIPTIONS
44 using SubId = IntegerId;
45 using MonId = IntegerId;
46 using SubMonId = std::pair<SubId, MonId>;
47 ContextMap<SubId, services::detail::SubscriptionContext> subscriptions;
48 ContextMap<SubMonId, services::detail::MonitoredItemContext> monitoredItems;
49 std::function<void(IntegerId)> subscriptionInactivityCallback;
50#endif
51};
52
53} // namespace opcua::detail
UA_SessionState
UA_SecureChannelState
uint32_t IntegerId
IntegerId.
Definition types.hpp:124