メインコンテンツまでスキップ

BrowseNext

子ノードがサーバー側の一ページあたりの制限を超えた場合、サーバーはBrowseResult内に空ではない( continuation_point ページ送りトークン)を返します。これを BrowseWithPaging そのまま受け取り、を使用して次の BrowseNext ページを取得してください。(Browse 取得したは破棄 CP されるため、ページ送りを行うにはから始める BrowseWithPaging 必要があります。)

事前学習
  • を手に入れたいなら、必ず~を使わ ContinuationPoint なければならない BrowseWithPaging, 普通 Browse 破棄されます CP。

署名​

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 この場合、サーバー側は状態を解放するだけで、次のページを返さない。NULL となる BrowseResult 可能性がある――つまり、返される値は空 BrowsePage.references である。明示的に解放しない場合は、サーバー側のタイムアウトによる回収を待つことになる。具体的な所要時間はサーバー側の実装によって決まり、制御することは SDK できない。

注意​

  • continuation_point 不透明なバイト配列であり、 変更・解析はしないでください
  • 続きの読み込みは、サーバー側がこのバイト列に基づいて閲覧状態を特定することで行われます。同じページ continuation_point に戻れるという前提で、同じページを再利用することは想定しないでください。
  • サーバー側で同時に保持できる数は、サーバー ContinuationPoint 側の実装によって決まります。制限もキャッシュ SDK もありません。処理が完了したときや処理を中止したときは、自動的に CP 空にするか、明示的に解放してください。

次のステップ​