From eeb7f2424384cbe5b74883fb90e8dc248899ff33 Mon Sep 17 00:00:00 2001 From: Rh4096 Date: Thu, 15 Aug 2024 18:01:26 +0700 Subject: [PATCH] xeontech --- prts-server/src/models/misc.rs | 18 ++++++++++++++++++ prts-server/src/models/mod.rs | 5 +++++ prts-server/src/models/payload.rs | 1 - prts-server/src/models/payload/mod.rs | 0 prts-server/src/server/game/account.rs | 6 +++++- prts-server/src/server/game/misc.rs | 15 +++++++++++++++ prts-server/src/server/game/mod.rs | 1 + prts-server/src/server/routes.rs | 17 ++++++++++++++--- 8 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 prts-server/src/models/misc.rs delete mode 100644 prts-server/src/models/payload.rs create mode 100644 prts-server/src/models/payload/mod.rs create mode 100644 prts-server/src/server/game/misc.rs diff --git a/prts-server/src/models/misc.rs b/prts-server/src/models/misc.rs new file mode 100644 index 0000000..972ba29 --- /dev/null +++ b/prts-server/src/models/misc.rs @@ -0,0 +1,18 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize)] +pub struct EventResponse<'a> { + code: u16, + msg: &'a str, + next: u16, +} + +pub const EVENT: EventResponse = EventResponse { code: 200, msg: "OK", next: 180 }; + +#[derive(Deserialize, Serialize)] +pub struct MiscResponse<'a> { + code: u16, + msg: &'a str, +} + +pub const BATCH_EVENT: MiscResponse = MiscResponse { code: 200, msg: "OK" }; diff --git a/prts-server/src/models/mod.rs b/prts-server/src/models/mod.rs index 6b9d1e4..58b6a47 100644 --- a/prts-server/src/models/mod.rs +++ b/prts-server/src/models/mod.rs @@ -1,11 +1,16 @@ use serde::{Deserialize, Serialize}; pub mod account; +mod misc; pub mod online; pub mod payload; pub mod prod; pub mod social; +pub use account::*; + +pub use misc::*; + /// Represent an empty Object. #[derive(Serialize, Deserialize, Default)] pub struct EmptyMap {} diff --git a/prts-server/src/models/payload.rs b/prts-server/src/models/payload.rs deleted file mode 100644 index 8b13789..0000000 --- a/prts-server/src/models/payload.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/prts-server/src/models/payload/mod.rs b/prts-server/src/models/payload/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/prts-server/src/server/game/account.rs b/prts-server/src/server/game/account.rs index 5a82620..2e90019 100644 --- a/prts-server/src/server/game/account.rs +++ b/prts-server/src/server/game/account.rs @@ -1,7 +1,7 @@ use axum::{http::HeaderMap, Json}; use uuid::Uuid; -use crate::models::account::AccountLogin; +use crate::models::{account::AccountLogin, MiscResponse, BATCH_EVENT}; pub async fn login(header: HeaderMap) -> Json { let uid = header.get("Uid").and_then(|v| v.to_str().ok()).map(|s| s.to_string()).unwrap_or_else(|| Uuid::new_v4().to_string()); @@ -10,3 +10,7 @@ pub async fn login(header: HeaderMap) -> Json { } pub async fn sync_data() {} + +pub async fn sync_push_data<'a>() -> Json> { + Json(BATCH_EVENT) +} diff --git a/prts-server/src/server/game/misc.rs b/prts-server/src/server/game/misc.rs new file mode 100644 index 0000000..fe2844f --- /dev/null +++ b/prts-server/src/server/game/misc.rs @@ -0,0 +1,15 @@ +use axum::Json; + +use crate::models::{EventResponse, MiscResponse, BATCH_EVENT, EVENT}; + +pub async fn event<'a>() -> Json> { + Json(EVENT) +} + +pub async fn batch_event<'a>() -> Json> { + Json(BATCH_EVENT) +} + +pub async fn beat<'a>() -> Json> { + Json(BATCH_EVENT) +} diff --git a/prts-server/src/server/game/mod.rs b/prts-server/src/server/game/mod.rs index b0edc6c..31e0f74 100644 --- a/prts-server/src/server/game/mod.rs +++ b/prts-server/src/server/game/mod.rs @@ -1 +1,2 @@ pub mod account; +pub mod misc; diff --git a/prts-server/src/server/routes.rs b/prts-server/src/server/routes.rs index ab553cd..ea96a31 100644 --- a/prts-server/src/server/routes.rs +++ b/prts-server/src/server/routes.rs @@ -8,7 +8,10 @@ use tracing::Level; use crate::{models::PlayerDataDeltaStatic, route}; -use super::core::{asset, prod_cfg}; +use super::{ + core::{asset, prod_cfg}, + game::{account, misc}, +}; pub fn app() -> Router { let trace = TraceLayer::new_for_http() @@ -18,7 +21,11 @@ pub fn app() -> Router { .on_failure(DefaultOnFailure::default().level(Level::ERROR)) .on_response(DefaultOnResponse::default().level(Level::DEBUG)); - Router::new().nest("/config/prod", prod_config_routes()).merge(misc_routes()).layer(trace).fallback(fallback) + Router::new().nest("/config/prod", prod_config_routes()).nest("/account", account_routes()).merge(misc_routes()).layer(trace).fallback(fallback) +} + +fn account_routes() -> Router { + Router::new().route("/syncPushMessage", post(account::sync_push_data)) } fn prod_config_routes() -> Router { @@ -32,7 +39,11 @@ fn prod_config_routes() -> Router { } fn misc_routes() -> Router { - Router::new().route("/assetbundle/official/Android/assets/:hash/:name", get(asset::get_file)) + Router::new() + .route("/assetbundle/official/Android/assets/:hash/:name", get(asset::get_file)) + .route("/event", post(misc::event)) + .route("/batch_event", post(misc::batch_event)) + .route("/beat", post(misc::beat)) } async fn fallback() -> Json {