Fix SSE
This commit is contained in:
parent
adfddfc9cf
commit
e51c8991ac
2 changed files with 13 additions and 13 deletions
10
src/main.rs
10
src/main.rs
|
@ -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?;
|
||||
|
||||
loop {
|
||||
buffer.clear();
|
||||
reader.read_line(&mut buffer).await?;
|
||||
if buffer == "OK\n" {
|
||||
break;
|
||||
}
|
||||
|
||||
let (_, changed) = buffer
|
||||
.trim_end()
|
||||
.split_once(": ")
|
||||
.ok_or(anyhow!("unexpected response from MPD"))?;
|
||||
sender.send(changed, "", None).await?;
|
||||
|
||||
buffer.clear();
|
||||
reader.read_line(&mut buffer).await?;
|
||||
if buffer != "OK\n" {
|
||||
Err(anyhow!("mpd didn't return OK"))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue