1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 17:59:24 +02:00

fix: fires the connect and disconnect again (#1548)

This commit is contained in:
Felix Prillwitz 2025-08-24 12:27:53 +02:00 committed by GitHub
parent 78ce118d32
commit 9d0e39f9c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -898,8 +898,8 @@ impl SpircTask {
&& cluster.active_device_id != self.session.device_id(); && cluster.active_device_id != self.session.device_id();
if became_inactive { if became_inactive {
info!("device became inactive"); info!("device became inactive");
self.connect_state.became_inactive(&self.session).await?; self.handle_disconnect().await?;
self.handle_stop() self.handle_stop();
} else if self.connect_state.is_active() { } else if self.connect_state.is_active() {
// fixme: workaround fix, because of missing information why it behaves like it does // fixme: workaround fix, because of missing information why it behaves like it does
// background: when another device sends a connect-state update, some player's position de-syncs // background: when another device sends a connect-state update, some player's position de-syncs
@ -1102,10 +1102,10 @@ impl SpircTask {
ContextAction::Replace, ContextAction::Replace,
)); ));
self.handle_activate();
let timestamp = self.now_ms(); let timestamp = self.now_ms();
let state = &mut self.connect_state; let state = &mut self.connect_state;
state.set_active(true);
state.handle_initial_transfer(&mut transfer); state.handle_initial_transfer(&mut transfer);
// adjust active context, so resolve knows for which context it should set up the state // adjust active context, so resolve knows for which context it should set up the state

View file

@ -29,7 +29,7 @@ use futures_util::future::IntoStream;
use http::{Uri, header::HeaderValue}; use http::{Uri, header::HeaderValue};
use hyper::{ use hyper::{
HeaderMap, Method, Request, HeaderMap, Method, Request,
header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, HeaderName, RANGE}, header::{ACCEPT, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderName, RANGE},
}; };
use hyper_util::client::legacy::ResponseFuture; use hyper_util::client::legacy::ResponseFuture;
use protobuf::{Enum, Message, MessageFull}; use protobuf::{Enum, Message, MessageFull};
@ -482,6 +482,7 @@ impl SpClient {
let mut request = Request::builder() let mut request = Request::builder()
.method(method) .method(method)
.uri(url) .uri(url)
.header(CONTENT_LENGTH, body.len())
.body(Bytes::copy_from_slice(body))?; .body(Bytes::copy_from_slice(body))?;
// Reconnection logic: keep getting (cached) tokens because they might have expired. // Reconnection logic: keep getting (cached) tokens because they might have expired.