Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set resource ID to 0 while listening in InMemoryRpcServer. #167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/communication/in_memory_rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ impl RpcServer for InMemoryRpcServer {
});
self.transport
.register_listener(
origin_filter.unwrap_or(&UUri::any()),
origin_filter.unwrap_or(&UUri::any_with_resource_id(
crate::uri::RESOURCE_ID_RESPONSE,
)),
Some(&sink_filter),
listener.clone(),
)
Expand Down Expand Up @@ -258,7 +260,9 @@ impl RpcServer for InMemoryRpcServer {
let listener = entry.get().to_owned();
self.transport
.unregister_listener(
origin_filter.unwrap_or(&UUri::any()),
origin_filter.unwrap_or(&UUri::any_with_resource_id(
crate::uri::RESOURCE_ID_RESPONSE,
)),
Some(&sink_filter),
listener,
)
Expand Down Expand Up @@ -310,7 +314,9 @@ mod tests {
let request_handler = Arc::new(MockRequestHandler::new());
let mut transport = MockTransport::new();
let uri_provider = new_uri_provider();
let expected_source_filter = origin_filter.clone().unwrap_or(UUri::any());
let expected_source_filter = origin_filter
.clone()
.unwrap_or(UUri::any_with_resource_id(0));
let param_check = move |source_filter: &UUri,
sink_filter: &Option<&UUri>,
_listener: &Arc<dyn UListener>| {
Expand Down
7 changes: 6 additions & 1 deletion src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,16 @@ impl UUri {

/// Gets a URI that consists of wildcards only and therefore matches any URI.
pub fn any() -> Self {
Self::any_with_resource_id(WILDCARD_RESOURCE_ID)
}

/// Gets a URI that consists of wildcards and the specific resource ID.
pub fn any_with_resource_id(resource_id: u32) -> Self {
evshary marked this conversation as resolved.
Show resolved Hide resolved
UUri {
authority_name: WILDCARD_AUTHORITY.to_string(),
ue_id: WILDCARD_ENTITY_ID,
ue_version_major: WILDCARD_ENTITY_VERSION,
resource_id: WILDCARD_RESOURCE_ID,
resource_id,
..Default::default()
}
}
Expand Down