Fix SSE
This commit is contained in:
parent
adfddfc9cf
commit
e51c8991ac
2 changed files with 13 additions and 13 deletions
22
src/main.rs
22
src/main.rs
|
@ -127,18 +127,18 @@ async fn sse(_req: tide::Request<()>, sender: tide::sse::Sender) -> tide::Result
|
||||||
loop {
|
loop {
|
||||||
stream.write_all(b"idle playlist player\n").await?;
|
stream.write_all(b"idle playlist player\n").await?;
|
||||||
|
|
||||||
buffer.clear();
|
loop {
|
||||||
reader.read_line(&mut buffer).await?;
|
buffer.clear();
|
||||||
let (_, changed) = buffer
|
reader.read_line(&mut buffer).await?;
|
||||||
.trim_end()
|
if buffer == "OK\n" {
|
||||||
.split_once(": ")
|
break;
|
||||||
.ok_or(anyhow!("unexpected response from MPD"))?;
|
}
|
||||||
sender.send(changed, "", None).await?;
|
|
||||||
|
|
||||||
buffer.clear();
|
let (_, changed) = buffer
|
||||||
reader.read_line(&mut buffer).await?;
|
.trim_end()
|
||||||
if buffer != "OK\n" {
|
.split_once(": ")
|
||||||
Err(anyhow!("mpd didn't return OK"))?;
|
.ok_or(anyhow!("unexpected response from MPD"))?;
|
||||||
|
sender.send(changed, "", None).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,8 +187,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="player">
|
<div class="player">
|
||||||
<div hx-trigger="load,sse:queue,sse:player" hx-get="/current"></div>
|
<div hx-trigger="load,sse:player" hx-get="/current"></div>
|
||||||
<div hx-trigger="load,sse:queue,sse:player" hx-get="/queue"></div>
|
<div hx-trigger="load,sse:playlist" hx-get="/queue"></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue