Skip to content

Commit a9ea5a1

Browse files
committed
fix: execute spirc commands after connection establishment
1 parent 385e02c commit a9ea5a1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

connect/src/spirc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct SpircTask {
7373

7474
/// the state management object
7575
connect_state: ConnectState,
76+
connect_established: bool,
7677

7778
play_request_id: Option<u64>,
7879
play_status: SpircPlayStatus,
@@ -226,6 +227,7 @@ impl Spirc {
226227
mixer,
227228

228229
connect_state,
230+
connect_established: false,
229231

230232
play_request_id: None,
231233
play_status: SpircPlayStatus::Stopped,
@@ -499,7 +501,7 @@ impl SpircTask {
499501
session_update,
500502
match |session_update| self.handle_session_update(session_update)
501503
},
502-
cmd = async { commands?.recv().await }, if commands.is_some() => if let Some(cmd) = cmd {
504+
cmd = async { commands?.recv().await }, if self.connect_established && commands.is_some() => if let Some(cmd) = cmd {
503505
if let Err(e) = self.handle_command(cmd).await {
504506
debug!("could not dispatch command: {}", e);
505507
}
@@ -825,6 +827,8 @@ impl SpircTask {
825827
self.session.device_id()
826828
);
827829

830+
self.connect_established = true;
831+
828832
let same_session = cluster.player_state.session_id == self.session.session_id()
829833
|| cluster.player_state.session_id.is_empty();
830834
if !cluster.active_device_id.is_empty() || !same_session {

0 commit comments

Comments
 (0)