#include <server.hpp>
High-level server class.
A server is usually created in two steps:
- Create and modify a server configuration (ServerConfig)
- Create a Server with a ServerConfig (move ownership to the Server instance)
The server expects that the configuration is not modified during runtime.
Use the handle() method to get access the underlying UA_Server instance and use the full power of open62541.
Don't overwrite the UA_ServerConfig::context pointer! The context pointer is used to store a pointer to the Server instance (for asWrapper(UA_Server*)) and to get access to the underlying server context.
- Examples
- custom_datatypes/server_custom_datatypes.cpp, events/server_events.cpp, method/server_method.cpp, method/server_method_async.cpp, server.cpp, server_accesscontrol.cpp, server_datasource.cpp, server_instantiation.cpp, server_logger.cpp, server_minimal.cpp, and server_valuecallback.cpp.
Definition at line 142 of file server.hpp.
◆ Server() [1/5]
opcua::Server::Server |
( |
| ) |
|
Create server with default configuration.
◆ Server() [2/5]
Create server with given configuration (move ownership to server).
◆ Server() [3/5]
Create server from native instance (move ownership to server).
◆ ~Server()
opcua::Server::~Server |
( |
| ) |
|
◆ Server() [4/5]
opcua::Server::Server |
( |
const Server & |
| ) |
|
|
delete |
◆ Server() [5/5]
opcua::Server::Server |
( |
Server && |
other | ) |
|
|
noexcept |
◆ config() [1/2]
◆ config() [2/2]
◆ createSubscription()
◆ handle() [1/2]
const UA_Server * opcua::Server::handle |
( |
| ) |
const |
|
noexcept |
◆ handle() [2/2]
◆ isRunning()
bool opcua::Server::isRunning |
( |
| ) |
const |
|
noexcept |
Check if the server is running.
◆ namespaceArray()
std::vector< String > opcua::Server::namespaceArray |
( |
| ) |
|
Get all defined namespaces.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ registerNamespace()
NamespaceIndex opcua::Server::registerNamespace |
( |
std::string_view |
uri | ) |
|
Register namespace. The new namespace index will be returned.
◆ run()
void opcua::Server::run |
( |
| ) |
|
◆ runIterate()
uint16_t opcua::Server::runIterate |
( |
| ) |
|
Run a single iteration of the server's main loop.
- Returns
- Maximum wait period until next Server::runIterate call (in ms)
◆ sessions()
std::vector< Session > opcua::Server::sessions |
( |
| ) |
|
◆ setCustomDataTypes()
void opcua::Server::setCustomDataTypes |
( |
Span< const DataType > |
dataTypes | ) |
|
|
inline |
◆ setVariableNodeDataSource() [1/2]
◆ setVariableNodeDataSource() [2/2]
void opcua::Server::setVariableNodeDataSource |
( |
const NodeId & |
id, |
|
|
std::unique_ptr< DataSourceBase > && |
source |
|
) |
| |
Set data source for variable node (move ownership to server).
◆ setVariableNodeValueCallback() [1/2]
void opcua::Server::setVariableNodeValueCallback |
( |
const NodeId & |
id, |
|
|
std::unique_ptr< ValueCallbackBase > && |
callback |
|
) |
| |
Set value callback for variable node (move ownership to server).
◆ setVariableNodeValueCallback() [2/2]
◆ stop()
void opcua::Server::stop |
( |
| ) |
|
Stop the server's main loop.
◆ asWrapper()
Convert native UA_Server pointer to its wrapper instance.
The native server must be owned by a Server instance.
◆ detail::getContext
detail::ServerContext & detail::getContext |
( |
Server & |
server | ) |
|
|
friend |
◆ getAsyncOperation()
Get the next queued async operation if available.
Async operations are queued by nodes with async operations enabled (see useAsyncOperation).
◆ operator!=()
◆ operator==()
◆ runAsyncOperation()
Run the provided async operation.
◆ useAsyncOperation()
void useAsyncOperation |
( |
Server & |
server, |
|
|
const NodeId & |
id, |
|
|
bool |
enabled |
|
) |
| |
|
related |
Enable or disable async operations for the specified node.
When enabled, operations on the node are queued and must processed by a worker thread using runAsyncOperation.
- Note
- Only supported for method nodes.