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

BrowseNext (C)

そのとき Browse 返された子ノードがサーバー側の一ページあたりの制限数を超えた場合、サーバーは BrowseResult 内に空ではない ContinuationPoint (次ページ表示トークン)を返します。 を使用して、次のページを取得 BrowseNext します。

事前学習
  • ~を手に入れたいなら、 ContinuationPoint まず~し Browse、次に~を調整し _GetContinuationPoint、~を参照してください。 Browse.
  • すべての子ノードのカプセル化テンプレートを直接入手したい場合は、こちらをご覧ください Browse 自動ページ分割.

API​

OPCUA_API DarraUa_Status OPCUA_CALL DarraUa_Session_BrowseNext(
DarraUa_SessionHandle h,
int32_t release_continuation_points, /* 1 = release, 0 = continue */
const uint8_t* continuation_point,
int32_t continuation_point_len,
DarraUa_BrowseResult** out_result);

OPCUA_API const uint8_t* OPCUA_CALL
DarraUa_BrowseResult_GetContinuationPoint(
const DarraUa_BrowseResult* r, int32_t* out_len);
パラメータ説明
release_continuation_points1 = ページ送りの継続を中止し、サーバーがリソースを解放する(参照を返さない)
continuation_point / _len前回、BrowseResult から発行された継続閲覧権限
out_result参考文献:本ページに記載の参考文献に加え、新規のものを含む ContinuationPoint

_GetContinuationPoint 戻りポインタは内部 BrowseResult バッファを指し、 「無料」はダメ, なお、これ以降は無効 BrowseResult_Delete となります。保存したい場合は、ご自身でコピーしてください。

ページめくりの完全な例​

#include <opcua/opcua.h>
#include <stdio.h>
#include <string.h>

static void browse_all(DarraUa_SessionHandle h, const char* root)
{
DarraUa_BrowseResult* page = NULL;
DarraUa_Status st = DarraUa_Session_BrowseNode(
h, root, UA_NODE_CLASS_UNSPECIFIED, &page);
if (!UA_STATUS_IS_GOOD(st) || !page) return;

uint32_t total = 0;
char id_buf[128];

while (page) {
uint32_t n = DarraUa_BrowseResult_GetCount(page);
for (uint32_t i = 0; i < n; ++i) {
const DarraUa_ReferenceDescription* rd =
DarraUa_BrowseResult_GetReference(page, i);
DarraUa_Ref_GetNodeIdString(rd, id_buf, (int32_t)sizeof(id_buf));
printf(" %s\n", id_buf);
}
total += n;

/* 伝票を取り出して、コピーする(有効 page_Delete 期限が切れてしまうため) */
int32_t cp_len = 0;
const uint8_t* cp = DarraUa_BrowseResult_GetContinuationPoint(page, &cp_len);
if (!cp || cp_len <= 0) {
DarraUa_BrowseResult_Delete(page);
break;
}
uint8_t cp_copy[256]; /* 不透明バイト。クライアントは転送のみを行い、解析は行わない。 */
if (cp_len > (int32_t)sizeof(cp_copy)) {
DarraUa_BrowseResult_Delete(page);
break; /* 長さが異常、破棄 */
}
memcpy(cp_copy, cp, (size_t)cp_len);
DarraUa_BrowseResult_Delete(page);

/* 次のページへ */
page = NULL;
DarraUa_Session_BrowseNext(
h, /*release*/ 0, cp_copy, cp_len, &page);
}

printf("Total %u children\n", (unsigned)total);
}

能動的な解放(サーバーリソースの節約)​

サーバー側は各メンテナンス ContinuationPoint 状態ごとにリソースを消費します。途中で処理を続行したくない場合は、明示 release=1 的に解放するように設定してください:

DarraUa_BrowseResult* released = NULL;
DarraUa_Session_BrowseNext(h, /*release*/ 1, cp_copy, cp_len, &released);
/* release=1 はページ送りの継続を中止することを意味します:サーバーはリソースを解放し、これ以降 references を返さなくなります。
* この時点で「released」と表示されるのは正常な動作 NULL ですので、設定を変更しないでください。 _Delete. */

out_result に NULL を渡すことは許可されていません — NULL を渡すと UA_STATUS_INVALID_ARGUMENT を直接返します。

伝票の回収タイミングはサーバー側で決定され、クライアント側では照会できません。ページ送りを行わなくなった場合は、明示的に release=1 返却してください。

注意​

  • ContinuationPoint 不透明なバイト配列であり、 変更・解析はしないでください
  • ページめくりには直近のBrowseResult 提示された継続トークン:ページをめくるたびに新しい伝票が発行されますので、古い伝票は破棄してください。
  • サーバー側で許可される同時保持可能な更新トークンの数はサーバー側で決定され、クライアント側からは確認できません。ページめくりを行わなくなった場合は、できるだけ早く返却 release=1 してください。
  • ページめくりは、同じセッション内で連続して行ってください。途中で中断しないでください Disconnect / Close

次のステップ​