async_notify/
async_notify.rs1extern crate ssdp;
2
3use std::io::{self, Read};
4use std::thread;
5use std::time::Duration;
6
7use ssdp::FieldMap;
8use ssdp::header::{HeaderMut, NT, NTS, USN};
9use ssdp::message::{NotifyListener, NotifyMessage, Listen, Multicast};
10
11fn main() {
12 thread::spawn(|| {
13 for (msg, src) in NotifyListener::listen().unwrap() {
14 println!("Received The Following Message From {}:\n{:?}\n", src, msg);
15 }
16 });
17
18 thread::sleep(Duration::new(1, 0));
20
21 let mut message = NotifyMessage::new();
23
24 message.set(NTS::ByeBye);
26 message.set(NT(FieldMap::upnp("rootdevice")));
27 message.set(USN(FieldMap::uuid("Hello, This Is Not A UUID!!!"), None));
28
29 message.multicast().unwrap();
30
31 println!("Press Enter When You Wish To Exit...\n");
33 let input = io::stdin();
34
35 input.bytes().next();
36}