use axum::extract::{Json, State}; use export::rest::{AppResponseData, NoData}; use serde::Deserialize; use utoipa::ToSchema; use crate::errors::ApiError; use crate::services::service::ChatService; #[derive(Debug, Clone, Deserialize, ToSchema)] pub struct ConnectionCmd { pub user_id: i64, pub session_id: String, } pub async fn open( State(service): State, Json(cmd): Json, ) -> Result, ApiError> { service .connection_open(cmd.user_id, &cmd.session_id) .await?; Ok(AppResponseData::empty()) } pub async fn heartbeat( State(service): State, Json(cmd): Json, ) -> Result, ApiError> { service .connection_touch(cmd.user_id, &cmd.session_id) .await?; Ok(AppResponseData::empty()) } pub async fn close( State(service): State, Json(cmd): Json, ) -> Result, ApiError> { service .connection_close(cmd.user_id, &cmd.session_id) .await?; Ok(AppResponseData::empty()) }