This commit is contained in:
Sijmen 2023-04-25 16:44:05 +02:00
parent adfddfc9cf
commit e51c8991ac
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
2 changed files with 13 additions and 13 deletions

View File

@ -127,18 +127,18 @@ async fn sse(_req: tide::Request<()>, sender: tide::sse::Sender) -> tide::Result
loop {
stream.write_all(b"idle playlist player\n").await?;
buffer.clear();
reader.read_line(&mut buffer).await?;
let (_, changed) = buffer
.trim_end()
.split_once(": ")
.ok_or(anyhow!("unexpected response from MPD"))?;
sender.send(changed, "", None).await?;
loop {
buffer.clear();
reader.read_line(&mut buffer).await?;
if buffer == "OK\n" {
break;
}
buffer.clear();
reader.read_line(&mut buffer).await?;
if buffer != "OK\n" {
Err(anyhow!("mpd didn't return OK"))?;
let (_, changed) = buffer
.trim_end()
.split_once(": ")
.ok_or(anyhow!("unexpected response from MPD"))?;
sender.send(changed, "", None).await?;
}
}
}

View File

@ -187,8 +187,8 @@
</div>
<div class="player">
<div hx-trigger="load,sse:queue,sse:player" hx-get="/current"></div>
<div hx-trigger="load,sse:queue,sse:player" hx-get="/queue"></div>
<div hx-trigger="load,sse:player" hx-get="/current"></div>
<div hx-trigger="load,sse:playlist" hx-get="/queue"></div>
</div>
</body>
</html>