Skip to main content

BrowseNext (C)

When Browse When the number of returned child nodes exceeds the server's single-page limit, the server returns a non-empty BrowseResult (paging token) ContinuationPoint in. Use BrowseNext to retrieve the next page.

Prerequisite Reading
  • To get, you ContinuationPoint must first Browse, then adjust _GetContinuationPoint; see Browse.
  • To get the encapsulation template for all child nodes directly, see Browse Automatic Pagination.

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);
ParametersNote
release_continuation_points1 = Abort the continuation; the server releases resources (no references are returned)
continuation_point / _lenThe last renewal token provided by BrowseResult
out_resultBibliography, including the references on this page + the new ContinuationPoint

_GetContinuationPoint The returned pointer points to the internal BrowseResult buffer, Not free, and it will expire BrowseResult_Delete later. If you want to keep it, please copy it yourself.

Complete Page-Turning Example​

#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;

/* Take the continuation voucher and make a copy of it (because it will page_Delete expire). */
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]; /* Opaque bytes; the client only passes them along without parsing them */
if (cp_len > (int32_t)sizeof(cp_copy)) {
DarraUa_BrowseResult_Delete(page);
break; /* Invalid length, abort */
}
memcpy(cp_copy, cp, (size_t)cp_len);
DarraUa_BrowseResult_Delete(page);

/* Turn to the next page */
page = NULL;
DarraUa_Session_BrowseNext(
h, /*release*/ 0, cp_copy, cp_len, &page);
}

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

Proactive Release (Saves Server Resources)​

The server maintains ContinuationPoint a state for each one, which consumes resources. If you decide to stop browsing partway through, call the method to explicitly release=1 release it:

DarraUa_BrowseResult* released = NULL;
DarraUa_Session_BrowseNext(h, /*release*/ 1, cp_copy, cp_len, &released);
/* release=1 indicates that the continuation is abandoned: the server releases resources and no longer returns references,
* At this point, it is NULL normal for "released" to appear; do not adjust it. _Delete. */

out_result Pass-by-value is not allowed —NULL pass-by-value returns directly NULL UA_STATUS_INVALID_ARGUMENT.

The timing of token renewal is determined by the server; the client cannot query this information. When pagination is no longer required, explicitly release=1 return the token.

Note​

  • ContinuationPoint is an opaque byte array, Do not modify / parse
  • To turn the page, useMost recentBrowseResult continuation token provided: A new voucher will be issued for each page turned; please discard the old voucher.
  • The number of renewal tokens that can be held simultaneously is determined by the server; clients cannot query this information. release=1 Returns them as soon as possible when you are no longer turning pages.
  • Please turn the pages consecutively within the same session; do not stop in the middle Disconnect / Close

Next Step​