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_points | 1 = 페이지 넘김을 중단하고, 서버가 리소스를 해제함 (references를 반환하지 않음) |
| 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반납하십시오. - 페이지 넘기기는 동일한 세션 내에서 연속적으로 완료해 주시고, 도중에 중단하지 마십시오 /
DisconnectClose