This commit is contained in:
Tony Rewin 2023-10-02 18:27:55 +03:00
parent 8623d8b6b4
commit 002a94afdc

View File

@ -118,16 +118,18 @@ async fn sse_handler(
pubsub.subscribe(format!("chat:{}", chat_id)).await.unwrap();
}
let server_event = rx.recv().await.unwrap();
let _: () = con
.srem("authors-online", &author_id)
.await
.unwrap();
// Later in the sse_handler function
let server_event = rx.recv().await.unwrap();
let server_event_stream = futures::stream::once(async move { Ok::<_, actix_web::Error>(Bytes::from(server_event)) });
HttpResponse::Ok()
.append_header(("content-type", "text/event-stream"))
.streaming(server_event)
.streaming(server_event_stream)
}
#[actix_web::main]