mirror of
https://github.com/actix/examples
synced 2025-06-26 09:17:41 +02:00
fmt
This commit is contained in:
@ -37,10 +37,8 @@ impl Broadcaster {
|
||||
|
||||
fn spawn_ping(me: Data<Mutex<Self>>) {
|
||||
actix_web::rt::spawn(async move {
|
||||
let mut task = IntervalStream::new(interval_at(
|
||||
Instant::now(),
|
||||
Duration::from_secs(10),
|
||||
));
|
||||
let mut task =
|
||||
IntervalStream::new(interval_at(Instant::now(), Duration::from_secs(10)));
|
||||
|
||||
while task.next().await.is_some() {
|
||||
me.lock().remove_stale_clients();
|
||||
@ -85,10 +83,7 @@ pub struct Client(ReceiverStream<Bytes>);
|
||||
impl Stream for Client {
|
||||
type Item = Result<Bytes, Error>;
|
||||
|
||||
fn poll_next(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
match Pin::new(&mut self.0).poll_next(cx) {
|
||||
Poll::Ready(Some(v)) => Poll::Ready(Some(Ok(v))),
|
||||
Poll::Ready(None) => Poll::Ready(None),
|
||||
|
@ -46,10 +46,7 @@ async fn new_client(broadcaster: Data<Mutex<Broadcaster>>) -> impl Responder {
|
||||
.streaming(rx)
|
||||
}
|
||||
|
||||
async fn broadcast(
|
||||
msg: Path<String>,
|
||||
broadcaster: Data<Mutex<Broadcaster>>,
|
||||
) -> impl Responder {
|
||||
async fn broadcast(msg: Path<String>, broadcaster: Data<Mutex<Broadcaster>>) -> impl Responder {
|
||||
broadcaster.lock().send(&msg.into_inner());
|
||||
HttpResponse::Ok().body("msg sent")
|
||||
}
|
||||
|
Reference in New Issue
Block a user