본문으로 건너뛰기

BrowseNext

Browse / BrowseWithPaging 반환된 자노드가 서버의 단일 페이지 제한을 초과할 경우, 서버는 비어 있지 않은 ContinuationPoint(다음 페이지로 넘어가기 위한 토큰)를 반환합니다. 이를 사용하여 browse_next로 다음 페이지를 불러옵니다.

사전 읽기
  • ~를 얻으려면 ~를 ContinuationPoint 사용해야 합니다 BrowseWithPaging, 일반 Browse 버려집니다 CP.

서명​

pub fn Session::browse_next(
&self,
continuation_point: &[u8],
release: bool,
) -> Result<BrowsePage, OpcUaError>;
매개변수설명
continuation_point이전 Browse / BrowseNext 이 반환한 계속 포인트
releasetrue = 추가 변환 포기, 서버 측에서 리소스 해제 (references 반환하지 않음)

BrowsePage 필드​

pub struct BrowsePage {
pub references: Vec<Reference>,
/// Some(비어 있지 않음)은 더 많은 페이지가 있음을 나타내며, 를 클릭하여 browse_next 다음 페이지를 볼 수 있습니다.
/// None / Some(빈칸)은 더 이상 페이지가 없음을 나타냅니다.
pub continuation_point: Option<Vec<u8>>,
}

완전한 페이지 넘기기 예시​

use darra_opcua::NodeClass;

let mut page = s.browse_with_paging("ns=2;s=BigFolder", NodeClass::Unspecified)?;
let mut all_refs = page.references.clone();

while let Some(cp) = page.continuation_point.take() {
if cp.is_empty() { break; }
page = s.browse_next(&cp, false)?;
all_refs.extend(page.references.iter().cloned());
}

println!("Total {} children", all_refs.len());

능동적 해제 (서버 리소스 절약)​

서버는 각 ContinuationPoint 상태를 유지하며 리소스를 차지합니다. 도중에 더 이상 처리하지 않으려면, release=true 명시적으로 해제합니다:

s.browse_next(&cp, true)?;

그렇지 않으면 이러한 요소들은 서버가 스스로 회수할 때까지 계속 서버 리소스를 점유하게 ContinuationPoint 됩니다. 회수 시점은 서버 구현에 따라 결정되며 (서버마다 다릅니다), 이에 의존해서는 안 됩니다. 해제해야 할 경우 명시적으로 해제해야 합니다 release=true.

browse_all (추천)​

Session::browse_all 내부 루프 빈 ContinuationPoint 상태가 될 browse_next 때까지, 마지막으로 잔여 자원을 자동으로 해제:

pub fn browse_all(&self, node_id: &str, filter: NodeClass, max_pages: usize)
-> Result<Vec<Reference>, OpcUaError>;
  • max_pages — 안전 상한선: 서버 측에서 비정상적인 응답이 지속적으로 반환되어 무한 루프가 CP 발생하는 것을 방지합니다.
  • 에 도달하면 max_pages , 현재 를 CP 수동으로 해제한다
let all = s.browse_all("ns=2;s=BigFolder", NodeClass::Variable, 50)?;
println!("{} variables under BigFolder", all.len());

주의​

  • ContinuationPoint 불투명한 바이트 배열이며, 수정하지 마십시오 / 분석
  • 같은 것은 한 번만 사용할 ContinuationPoint 수 있습니다
  • 서버는 각 세션의 수에 상한을 ContinuationPoint 두고 있으며, 이 상한값은 서버마다 다릅니다. 상한을 초과했을 때의 처리 방식도 서버에 따라 결정됩니다 — 다 사용하면 해제하고, 쌓아두지 마세요.

다음 단계​