diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 43 | ||||
| -rw-r--r-- | src/notify.rs | 7 |
2 files changed, 32 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs index 94f8f3a..3ba3efa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,13 +80,13 @@ fn main() { .body(Body::from(notify::BODY_SET_URI)) .unwrap(); - let req2 = Request::builder() - .method("POST") - .uri("http://10.5.1.201:38400/serviceControl/AVTransport") - .header("Content-Type", "text/xml") - .header("SOAPACTION", notify::A_PLAY) - .body(Body::from(notify::BODY_PLAY)) - .unwrap(); + // let req2 = Request::builder() + // .method("POST") + // .uri("http://10.5.1.201:38400/serviceControl/AVTransport") + // .header("Content-Type", "text/xml") + // .header("SOAPACTION", notify::A_STOP) + // .body(Body::from(notify::BODY_STOP)) + // .unwrap(); let f = client .request(req1) @@ -95,14 +95,14 @@ fn main() { }) .map_err(|err| { println!("Something bad happened"); - }) - .and_then(move |_| { - client.request(req2).map(|res| { - println!("OK"); - }).map_err(|err| { - println!("Something bad2"); - }) }); + // .and_then(move |_| { + // client.request(req2).map(|res| { + // println!("OK"); + // }).map_err(|err| { + // println!("Something bad2"); + // }) + // }); rt.spawn(f); @@ -120,6 +120,21 @@ fn main() { if c == 113 { break; } + if c == 32 { + let req2 = Request::builder() + .method("POST") + .uri("http://10.5.1.201:38400/serviceControl/AVTransport") + .header("Content-Type", "text/xml") + .header("SOAPACTION", notify::A_PLAY) + .body(Body::from(notify::BODY_PLAY)) + .unwrap(); + let f = client.request(req2).map(|res| { + println!("OK"); + }).map_err(|err| { + println!("Err"); + }); + rt.spawn(f); + } } controller.destroy(); }); diff --git a/src/notify.rs b/src/notify.rs index da34131..f946fd0 100644 --- a/src/notify.rs +++ b/src/notify.rs @@ -15,8 +15,7 @@ pub const BODY_SET_URI: &'static str = r#"<?xml version='1.0' encoding='utf-8'?> </s:Body> </s:Envelope>"#; -pub const BODY_PLAY: &'static str = r#" -<?xml version='1.0' encoding='utf-8'?> +pub const BODY_PLAY: &'static str = r#"<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"> @@ -26,8 +25,7 @@ pub const BODY_PLAY: &'static str = r#" </s:Body> </s:Envelope>"#; -const BODY_STOP: &'static str = r#" -<?xml version='1.0' encoding='utf-8'?> +pub const BODY_STOP: &'static str = r#"<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <u:Stop xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"> @@ -39,3 +37,4 @@ const BODY_STOP: &'static str = r#" pub const A_SET: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"; pub const A_PLAY: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#Play"; +pub const A_STOP: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#Stop"; |
