Skip to content

Commit

Permalink
xeontech
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhelvetican committed Aug 15, 2024
1 parent ed22a7b commit eeb7f24
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 5 deletions.
18 changes: 18 additions & 0 deletions prts-server/src/models/misc.rs
Original file line number Diff line number Diff line change
@@ -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" };
5 changes: 5 additions & 0 deletions prts-server/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -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 {}
Expand Down
1 change: 0 additions & 1 deletion prts-server/src/models/payload.rs

This file was deleted.

Empty file.
6 changes: 5 additions & 1 deletion prts-server/src/server/game/account.rs
Original file line number Diff line number Diff line change
@@ -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<AccountLogin> {
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());
Expand All @@ -10,3 +10,7 @@ pub async fn login(header: HeaderMap) -> Json<AccountLogin> {
}

pub async fn sync_data() {}

pub async fn sync_push_data<'a>() -> Json<MiscResponse<'a>> {
Json(BATCH_EVENT)
}
15 changes: 15 additions & 0 deletions prts-server/src/server/game/misc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use axum::Json;

use crate::models::{EventResponse, MiscResponse, BATCH_EVENT, EVENT};

pub async fn event<'a>() -> Json<EventResponse<'a>> {
Json(EVENT)
}

pub async fn batch_event<'a>() -> Json<MiscResponse<'a>> {
Json(BATCH_EVENT)
}

pub async fn beat<'a>() -> Json<MiscResponse<'a>> {
Json(BATCH_EVENT)
}
1 change: 1 addition & 0 deletions prts-server/src/server/game/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod account;
pub mod misc;
17 changes: 14 additions & 3 deletions prts-server/src/server/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand All @@ -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<PlayerDataDeltaStatic> {
Expand Down

0 comments on commit eeb7f24

Please sign in to comment.