跳到主要内容

BrowseNext

子节点超过服务端单页限制时, 服务端会在 BrowseResult 里带回非空的 continuation_point (续翻凭证). BrowseWithPaging 把它原样交给你, 用 BrowseNext 继续拿下一页. (Browse 拿到 CP 也会丢掉, 所以要翻页只能从 BrowseWithPaging 起手.)

前置阅读

签名​

BrowseNext 是 Session 的成员方法.

namespace darra::opcua {

class Session {
public:
BrowsePage BrowseNext(
std::vector<uint8_t> const& continuation_point,
bool release = false);
};

}
参数说明
continuation_point上一次 Browse / BrowseNext 返回的续翻凭证
releasetrue = 放弃续翻, 服务端释放资源 (不返回 references)

BrowsePage 结构​

struct BrowsePage {
std::vector<Reference> references;
std::vector<uint8_t> continuation_point; // 空 = 无更多页
};

完整翻页例子​

#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::vector<Reference> all_refs = page.references;

while (!page.continuation_point.empty()) {
page = s.BrowseNext(page.continuation_point);
all_refs.insert(all_refs.end(), page.references.begin(), page.references.end());
}

std::cout << "Total " << all_refs.size() << " children\n";

主动释放 (节省服务端资源)​

服务端为每个 ContinuationPoint 维护状态, 占用资源. 如果中途不想继续翻, 调 release=true 显式释放:

s.BrowseNext(page.continuation_point, /*release=*/true);

release=true 时服务端只释放状态, 不返回下一页, BrowseResult 可能为 NULL —— 返回的 BrowsePage.references 是空的。不显式释放就等服务端自己的超时回收, 具体时长由服务端实现决定, SDK 不控制。

注意​

  • continuation_point 是不透明字节数组, 不要修改 / 解析
  • 续翻的推进由服务端按这个字节串定位浏览状态, 不要假设复用同一个 continuation_point 能回到某一页
  • 服务端能同时挂着多少个 ContinuationPoint 由服务端实现决定, SDK 不做限制也不缓存; 翻完或放弃时让 CP 自然为空或显式 release

下一步​