BrowseWithPaging
Browse Returns only the References list and discards ContinuationPoint; this is suitable for scenarios where there are "few known child nodes." When the number of child nodes may exceed the single-page limit (the client requests a fixed requestedMaxReferencesPerNode of 1000), use BrowseWithPaging to explicitly retrieve the BrowsePage to continue pagination.
Prerequisite Reading
- For continuing on the next page BrowseNext.
Signature
BrowseWithPaging Session It is a member method.
namespace darra::opcua {
class Session {
public:
BrowsePage BrowseWithPaging(
std::string const& node_id,
NodeClass filter = NodeClass::Unspecified);
};
}
Usage
#include <darra/opcua/client.hpp>
#include <iostream>
using namespace darra::opcua;
Session s("opc.tcp://localhost:4840");
s.Connect();
auto page = s.BrowseWithPaging("ns=2;s=BigFolder");
std::cout << "Got " << page.references.size()
<< " children, more = " << !page.continuation_point.empty() << "\n";
if (!page.continuation_point.empty()) {
auto next = s.BrowseNext(page.continuation_point);
std::cout << "Next page: " << next.references.size() << " more children\n";
}
When to Use Browse vs BrowseWithPaging
| Scenario | API |
|---|---|
| The number of child nodes is limited to the maximum allowed per page; pagination is not a concern. | Browse(...) |
| The number of child nodes is unknown | BrowseWithPaging(...) + loop BrowseNext |
| There could be thousands of child nodes | BrowseWithPaging(...) Required (otherwise, only the first page will be retrieved silently) |
| Browse Multiple Nodes at Once | BrowseMany(...) (Note: This does not BrowseMany return a value at this time.ContinuationPoint) |
Complete Template
This is a helper function
SDK you wrote yourself. NoneBrowseAll This API — The following passage is a combination BrowseWithPaging of BrowseNext + .User-Side Template, Copy it into your own project to use; do not run it #include externally.
// User-side helper function (non- SDK API): Automatically scroll through all pages
std::vector<darra::opcua::Reference> BrowseAll(
darra::opcua::Session& s,
std::string const& node_id,
darra::opcua::NodeClass filter = darra::opcua::NodeClass::Unspecified)
{
std::vector<darra::opcua::Reference> all;
auto page = s.BrowseWithPaging(node_id, filter);
all.insert(all.end(), page.references.begin(), page.references.end());
while (!page.continuation_point.empty()) {
page = s.BrowseNext(page.continuation_point);
all.insert(all.end(), page.references.begin(), page.references.end());
}
return all;
}