open62541pp 0.19.0
C++ wrapper of open62541
|
#include <client.hpp>
High-level client class.
A client is usually created in two steps:
Once a client is connected to an endpointUrl
, it is not possible to switch to another server. A new client has to be created for that.
Use the handle() method to get access the underlying UA_Server instance and use the full power of open62541.
Don't overwrite the UA_ClientConfig::clientContext pointer! The context pointer is used to store a pointer to the Client instance (for asWrapper(UA_Client*)) and to get access to the underlying client context.
Definition at line 130 of file client.hpp.
Public Member Functions | |
Client () | |
Client (ClientConfig &&config) | |
Client (UA_Client *native) | |
~Client () | |
Client (const Client &)=delete | |
Client (Client &&other) noexcept | |
Client & | operator= (const Client &)=delete |
Client & | operator= (Client &&other) noexcept |
ClientConfig & | config () noexcept |
const ClientConfig & | config () const noexcept |
std::vector< ApplicationDescription > | findServers (std::string_view serverUrl) |
std::vector< EndpointDescription > | getEndpoints (std::string_view serverUrl) |
void | setCustomDataTypes (Span< const DataType > dataTypes) |
void | onConnected (StateCallback callback) |
void | onDisconnected (StateCallback callback) |
void | onSessionActivated (StateCallback callback) |
void | onSessionClosed (StateCallback callback) |
void | onInactive (InactivityCallback callback) |
void | onSubscriptionInactive (SubscriptionInactivityCallback callback) |
void | connect (std::string_view endpointUrl) |
void | connectAsync (std::string_view endpointUrl) |
void | disconnect () |
void | disconnectAsync () |
bool | isConnected () noexcept |
std::vector< String > | namespaceArray () |
Subscription< Client > | createSubscription (const SubscriptionParameters ¶meters={}) |
std::vector< Subscription< Client > > | subscriptions () |
void | runIterate (uint16_t timeoutMilliseconds=1000) |
void | run () |
void | stop () |
bool | isRunning () const noexcept |
UA_Client * | handle () noexcept |
const UA_Client * | handle () const noexcept |
Friends | |
detail::ClientContext & | detail::getContext (Client &client) noexcept |
Related Symbols | |
(Note that these are not member symbols.) | |
Client * | asWrapper (UA_Client *client) noexcept |
bool | operator== (const Client &lhs, const Client &rhs) noexcept |
bool | operator!= (const Client &lhs, const Client &rhs) noexcept |
opcua::Client::Client | ( | ) |
Create client with default configuration.
|
explicit |
Create client with given configuration (move ownership to client).
|
explicit |
Create client from native instance (move ownership to client).
opcua::Client::~Client | ( | ) |
|
delete |
|
noexcept |
|
noexcept |
|
noexcept |
void opcua::Client::connect | ( | std::string_view | endpointUrl | ) |
Connect to the selected server.
The session authentification method is defined by the UserIdentityToken and is set with Client::setUserIdentityToken.
endpointUrl | Endpoint URL (for example opc.tcp://localhost:4840/open62541/server/ ) |
void opcua::Client::connectAsync | ( | std::string_view | endpointUrl | ) |
Asynchronously connect to the selected server.
Set a state callback, e.g. onConnected, to be notified when the connection status changes.
The session authentification method is defined by the UserIdentityToken and is set with Client::setUserIdentityToken.
endpointUrl | Endpoint URL (for example opc.tcp://localhost:4840/open62541/server/ ) |
Subscription< Client > opcua::Client::createSubscription | ( | const SubscriptionParameters & | parameters = {} | ) |
Create a subscription to monitor data changes and events.
void opcua::Client::disconnect | ( | ) |
Disconnect and close the connection to the server.
void opcua::Client::disconnectAsync | ( | ) |
Asynchronously disconnect and close the connection to the server.
Set a state callback, e.g. onDisconnected, to be notified when the connection status changes.
std::vector< ApplicationDescription > opcua::Client::findServers | ( | std::string_view | serverUrl | ) |
Gets a list of all registered servers at the given server.
serverUrl | Server URL (for example opc.tcp://localhost:4840 ) |
std::vector< EndpointDescription > opcua::Client::getEndpoints | ( | std::string_view | serverUrl | ) |
|
noexcept |
|
noexcept |
|
noexcept |
Check if client is connected (secure channel open).
|
noexcept |
Check if the client's main loop is running.
std::vector< String > opcua::Client::namespaceArray | ( | ) |
Get all defined namespaces.
void opcua::Client::onConnected | ( | StateCallback | callback | ) |
Set a state callback that will be called after the client is connected.
void opcua::Client::onDisconnected | ( | StateCallback | callback | ) |
Set a state callback that will be called after the client is disconnected.
void opcua::Client::onInactive | ( | InactivityCallback | callback | ) |
Set an inactivity callback.
Every UA_ClientConfig::connectivityCheckInterval (in ms), an async read request is performed on the server. The callback is called when the client receives no response for this request.
void opcua::Client::onSessionActivated | ( | StateCallback | callback | ) |
Set a state callback that will be called after the session is activated.
void opcua::Client::onSessionClosed | ( | StateCallback | callback | ) |
Set a state callback that will be called after the session is closed.
void opcua::Client::onSubscriptionInactive | ( | SubscriptionInactivityCallback | callback | ) |
Set a subscription inactivity callback.
The callback is called when the client does not receive a publish response after the defined delay of (publishingInterval * maxKeepAliveCount) + UA_ClientConfig::timeout)
.
void opcua::Client::run | ( | ) |
Run the client's main loop by. This method will block until Client::stop is called.
void opcua::Client::runIterate | ( | uint16_t | timeoutMilliseconds = 1000 | ) |
Run a single iteration of the client's main loop.
Listen on the network and process arriving asynchronous responses in the background. Internal housekeeping, renewal of SecureChannels and subscription management is done as well.
timeoutMilliseconds | Timeout in milliseconds |
Definition at line 165 of file client.hpp.
void opcua::Client::stop | ( | ) |
Stop the client's main loop.
std::vector< Subscription< Client > > opcua::Client::subscriptions | ( | ) |
Get all active subscriptions.
|
friend |
Definition at line 270 of file client.hpp.
Definition at line 265 of file client.hpp.