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

example code: refactor the query output prints and the register hostname #189

Merged
merged 4 commits into from
Mar 26, 2024
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
10 changes: 7 additions & 3 deletions examples/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ fn main() {
match event {
ServiceEvent::ServiceResolved(info) => {
println!(
"At {:?}: Resolved a new service: {} host: {} port: {} IP: {:?} TXT properties: {:?}",
"At {:?}: Resolved a new service: {}\n host: {}\n port: {}",
now.elapsed(),
info.get_fullname(),
info.get_hostname(),
info.get_port(),
info.get_addresses(),
info.get_properties(),
);
for addr in info.get_addresses().iter() {
println!(" Address: {}", addr);
}
for prop in info.get_properties().iter() {
println!(" Property: {}", prop);
}
}
other_event => {
println!("At {:?} : {:?}", now.elapsed(), &other_event);
Expand Down
4 changes: 2 additions & 2 deletions examples/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn main() {
// With `enable_addr_auto()`, we can give empty addrs and let the lib find them.
// If the caller knows specific addrs to use, then assign the addrs here.
let my_addrs = "";
let service_hostname = "mdns-example.local.";
let service_hostname = format!("{}{}", instance_name, &service_type);
let port = 3456;

// The key string in TXT properties is case insensitive. Only the first
Expand All @@ -55,7 +55,7 @@ fn main() {
let service_info = ServiceInfo::new(
&service_type,
instance_name,
service_hostname,
&service_hostname,
my_addrs,
port,
&properties[..],
Expand Down