#include <chrono>
#include <iostream>
#include <thread>
int main() {
server,
objectsId,
methodId,
"Greet",
const auto& name = input.
at(0).scalar<opcua::String>();
const auto greeting = std::string{"Hello "}.append(name);
},
opcua::ReferenceTypeId::HasComponent
);
result.code().throwIfBad();
opcua::useAsyncOperation(server, methodId, true);
std::thread workerThread{[&server]() {
while (true) {
const auto operation = opcua::getAsyncOperation(server);
if (operation.has_value()) {
opcua::runAsyncOperation(server, operation.value());
std::cout << "Async operation processed\n";
} else {
std::this_thread::sleep_for(std::chrono::milliseconds{10});
}
}
}};
workerThread.join();
}
void run()
Run the server's main loop. This method will block until Server::stop is called.
View to a contiguous sequence of objects, similar to std::span in C++20.
constexpr reference at(size_t index) const
Access element by index with bounds checking.
UA_MethodAttributes wrapper class.
Result< NodeId > addMethod(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, MethodCallback callback, Span< const Argument > inputArguments, Span< const Argument > outputArguments, const MethodAttributes &attributes, const NodeId &referenceType) noexcept
Add method.