Просмотр исходного кода

Add functions for sending commands to other clients.

Simon Persson 9 лет назад
Родитель
Сommit
08cb429a0c
1 измененных файлов с 32 добавлено и 0 удалено
  1. 32 0
      src/spirc.rs

+ 32 - 0
src/spirc.rs

@@ -113,6 +113,38 @@ impl SpircManager {
     pub fn devices(&self) -> HashMap<String, String> {
     pub fn devices(&self) -> HashMap<String, String> {
         self.0.lock().unwrap().devices.clone()
         self.0.lock().unwrap().devices.clone()
     }
     }
+
+    pub fn send_play(&mut self, recipient: &str) {
+        let mut internal = self.0.lock().unwrap();
+        send_cmd(&mut *internal,
+                 protocol::spirc::MessageType::kMessageTypePlay,
+                 Some(recipient),
+                 None);
+    }
+
+    pub fn send_pause(&mut self, recipient: &str) {
+        let mut internal = self.0.lock().unwrap();
+        send_cmd(&mut *internal,
+                 protocol::spirc::MessageType::kMessageTypePause,
+                 Some(recipient),
+                 None);
+    }
+
+    pub fn send_prev(&mut self, recipient: &str) {
+        let mut internal = self.0.lock().unwrap();
+        send_cmd(&mut *internal,
+                 protocol::spirc::MessageType::kMessageTypePrev,
+                 Some(recipient),
+                 None);
+    }
+
+    pub fn send_next(&mut self, recipient: &str) {
+        let mut internal = self.0.lock().unwrap();
+        send_cmd(&mut *internal,
+                 protocol::spirc::MessageType::kMessageTypeNext,
+                 Some(recipient),
+                 None);
+    }
 }
 }
 
 
 impl SpircInternal {
 impl SpircInternal {