소스 검색

Add functions for sending commands to other clients.

Simon Persson 9 년 전
부모
커밋
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> {
         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 {