open62541pp 0.18.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
server_context.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <functional>
5#include <map>
6#include <mutex>
7#include <utility> // pair
8
9#include "open62541pp/config.hpp"
12#include "open62541pp/detail/open62541/common.h" // UA_AccessControl
16#include "open62541pp/types.hpp" // NodeId, Variant
17#include "open62541pp/ua/types.hpp" // IntegerId
18
19namespace opcua::detail {
20
21struct NodeContext {
22 UniqueOrRawPtr<ValueCallbackBase> valueCallback;
23 UniqueOrRawPtr<DataSourceBase> dataSource;
24#ifdef UA_ENABLE_METHODCALLS
25 std::function<void(Span<const Variant> input, Span<Variant> output)> methodCallback;
26#endif
27};
28
29struct SessionRegistry {
30 using Context = void*;
31
32 decltype(UA_AccessControl::activateSession) activateSessionUser{nullptr};
33 decltype(UA_AccessControl::closeSession) closeSessionUser{nullptr};
34 std::map<NodeId, Context> sessions;
35 std::mutex mutex;
36};
37
38/**
39 * Internal storage for Server class.
40 */
41struct ServerContext {
42 ExceptionCatcher exceptionCatcher;
43 SessionRegistry sessionRegistry;
44 std::atomic<bool> running{false};
45 std::mutex mutexRun;
46
47#ifdef UA_ENABLE_SUBSCRIPTIONS
48 using SubId = IntegerId; // always 0
49 using MonId = IntegerId;
50 using SubMonId = std::pair<SubId, MonId>;
51 ContextMap<SubMonId, services::detail::MonitoredItemContext> monitoredItems;
52#endif
53
54 ContextMap<NodeId, NodeContext> nodeContexts;
55};
56
57} // namespace opcua::detail
uint32_t IntegerId
IntegerId.
Definition types.hpp:124
void(* closeSession)(UA_Server *server, UA_AccessControl *ac, const UA_NodeId *sessionId, void *sessionContext)
UA_StatusCode(* activateSession)(UA_Server *server, UA_AccessControl *ac, const UA_EndpointDescription *endpointDescription, const UA_ByteString *secureChannelRemoteCertificate, const UA_NodeId *sessionId, const UA_ExtensionObject *userIdentityToken, void **sessionContext)