#include <iostream>
#include <string_view>
switch (applicationType) {
return "Server";
return "Client";
return "Client and Server";
return "Discovery Server";
default:
return "Unknown";
}
}
switch (securityMode) {
return "Invalid";
return "None";
return "Sign";
return "Sign and Encrypt";
default:
return "No valid security mode";
}
}
int main() {
const auto servers = client.
findServers(
"opc.tcp://localhost:4840");
size_t serverIndex = 0;
for (const auto& server : servers) {
const auto& name = server.getApplicationUri();
std::cout
<< "Server[" << serverIndex++ << "] " << name << "\n"
<< "\tName: " << server.getApplicationName().getText() << "\n"
<< "\tApplication URI: " << server.getApplicationUri() << "\n"
<< "\tProduct URI: " << server.getProductUri() << "\n"
<< "\tApplication type: " << getEnumName(server.getApplicationType()) << "\n"
<< "\tDiscovery URLs:\n";
const auto discoveryUrls = server.getDiscoveryUrls();
if (discoveryUrls.empty()) {
std::cout << "No discovery urls provided. Skip endpoint search.";
}
for (const auto& url : discoveryUrls) {
std::cout << "\t- " << url << "\n";
}
for (const auto& url : discoveryUrls) {
size_t endpointIndex = 0;
for (const auto& endpoint : client.getEndpoints(url)) {
std::cout
<< "\tEndpoint[" << endpointIndex++ << "]:\n"
<< "\t- Endpoint URL: " << endpoint.getEndpointUrl() << "\n"
<< "\t- Transport profile: " << endpoint.getTransportProfileUri() << "\n"
<< "\t- Security mode: " << getEnumName(endpoint.getSecurityMode()) << "\n"
<< "\t- Security profile: " << endpoint.getSecurityPolicyUri() << "\n"
<< "\t- Security level: " << endpoint.getSecurityLevel() << "\n"
<< "\t- User identity token:\n";
for (const auto& token : endpoint.getUserIdentityTokens()) {
std::cout << "\t - " << token.getPolicyId() << "\n";
}
}
}
}
}
void setLogger(LogFunction func)
Set custom log function.
ClientConfig & config() noexcept
std::vector< ApplicationDescription > findServers(std::string_view serverUrl)
Gets a list of all registered servers at the given server.
UA_MESSAGESECURITYMODE_SIGN
UA_MESSAGESECURITYMODE_INVALID
UA_MESSAGESECURITYMODE_SIGNANDENCRYPT
UA_MESSAGESECURITYMODE_NONE
UA_APPLICATIONTYPE_DISCOVERYSERVER
UA_APPLICATIONTYPE_CLIENT
UA_APPLICATIONTYPE_CLIENTANDSERVER
UA_APPLICATIONTYPE_SERVER