1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! Server-Sent Events controller

use actix_web::{
    get,
    web::{Data, Query},
    Responder,
};

use crate::config::data::AppDataInner;
use crate::model::dto::ConnectToMapQueryParams;

/// Create a new SSE client.
#[get("")]
pub async fn connect_to_map(
    query: Query<ConnectToMapQueryParams>,
    state: Data<AppDataInner>,
) -> impl Responder {
    let query = query.into_inner();
    state.broadcaster.new_client(query.map_id).await
}