diff options
| author | Yuval Adam <_@yuv.al> | 2018-07-17 22:59:24 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2018-07-17 22:59:24 +0300 |
| commit | c3ea11e82d856817d123ea4a9a9d3576b17817a7 (patch) | |
| tree | 6554caa4d5ba3ad1729bad37420e136139714d42 /src/notify.rs | |
| parent | f0508f43937f1ec8b46d1428602c333f615aa607 (diff) | |
First round of runtime refactoring
Diffstat (limited to 'src/notify.rs')
| -rw-r--r-- | src/notify.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/notify.rs b/src/notify.rs index 60821cd..0d0877d 100644 --- a/src/notify.rs +++ b/src/notify.rs @@ -1,3 +1,10 @@ +extern crate hyper; +extern crate futures; + +use self::hyper::{Method, Request, Uri}; +use self::hyper::header::HeaderValue; +use self::hyper::body::Body; + const SOAP_ACTION_PREFIX: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#"; const ACTION_SET_URI: &'static str = "SetAVTransportURI"; const ACTION_PLAY: &'static str = "Play"; @@ -35,3 +42,21 @@ const BODY_STOP: &'static str = r#" </u:Stop> </s:Body> </s:Envelope>"#; + + +pub fn build_request(body: &'static str, action: &str) { + let uri: Uri = "http://10.5.1.201:38400/serviceControl/AVTransport".parse().unwrap(); + let mut req = Request::new(Body::from(body)); + *req.method_mut() = Method::POST; + *req.uri_mut() = uri.clone(); + req.headers_mut().insert("content-type", HeaderValue::from_str("text/xml").unwrap()); + req.headers_mut().insert("SOAPACTION", HeaderValue::from_str(action).unwrap()); +} + +pub fn set_uri() { + build_request(BODY_SET_URI, "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI") +} + +pub fn play() { + build_request(BODY_PLAY, "urn:schemas-upnp-org:service:AVTransport:1#Play") +} |
