Fix SSE
This commit is contained in:
parent
adfddfc9cf
commit
e51c8991ac
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 {
|
||||
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?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 New Issue