Commit 1abd0126 authored by 陈冲's avatar 陈冲

fix: 添加日志

parent ce0327b4
...@@ -576,34 +576,73 @@ async fn post_screen_game_score(game: &Game) { ...@@ -576,34 +576,73 @@ async fn post_screen_game_score(game: &Game) {
.unwrap_or_default(); .unwrap_or_default();
if auth_token.is_empty() { if auth_token.is_empty() {
println!(
"[screen_game_score] skip: empty auth token, wechat_id={}, item_num={}, score={}, rank={}, batch_no={}",
game.wechat_id, game.item_num, game.score, game.game_rank, game.batch_no
);
return; return;
} }
let code = game_code(game.item_num); let code = game_code(game.item_num);
if code.is_empty() { if code.is_empty() {
println!(
"[screen_game_score] skip: empty game code, wechat_id={}, item_num={}, score={}, rank={}, batch_no={}",
game.wechat_id, game.item_num, game.score, game.game_rank, game.batch_no
);
return; return;
} }
let resp = reqwest::Client::new() let body = json!({
.post("https://api.guocai365.org.cn/api/offline_clearance/user/screen_game_score")
.header("Authorization", auth_token)
.json(&json!({
"game_code": code, "game_code": code,
"score": game.score, "score": game.score,
"batch_no": game.batch_no, "batch_no": game.batch_no,
"rank_no": game.game_rank, "rank_no": game.game_rank,
})) });
dbg!(json!({
"event": "screen_game_score_post",
"wechat_id": game.wechat_id.clone(),
"auth_token_len": auth_token.len(),
"body": body.clone(),
}));
let resp = reqwest::Client::new()
.post("https://api.guocai365.org.cn/api/offline_clearance/user/screen_game_score")
.header("Authorization", auth_token)
.json(&body)
.send() .send()
.await; .await;
let log_msg = match resp { let log_msg = match resp {
Ok(resp) if resp.status().is_success() => return, Ok(resp) if resp.status().is_success() => {
let status = resp.status();
let msg = resp.text().await.unwrap_or_default();
dbg!(
"[screen_game_score] success: wechat_id={}, status={}, msg={}",
&game.wechat_id,
status,
msg
);
return;
}
Ok(resp) => { Ok(resp) => {
let status = resp.status(); let status = resp.status();
let body = resp.text().await.unwrap_or_default(); let body = resp.text().await.unwrap_or_default();
dbg!(json!({
"event": "screen_game_score_fail",
"wechat_id": game.wechat_id.clone(),
"status": status.as_u16(),
"body": body.clone(),
}));
format!("提交第三方大屏游戏分数失败: {status}, {body}") format!("提交第三方大屏游戏分数失败: {status}, {body}")
} }
Err(err) => err.to_string(), Err(err) => {
dbg!(json!({
"event": "screen_game_score_error",
"wechat_id": game.wechat_id.clone(),
"err": err.to_string(),
}));
err.to_string()
}
}; };
{ {
...@@ -1273,6 +1312,11 @@ pub async fn on_connect(_io: SocketIo, socket: SocketRef, Data(data): Data<Value ...@@ -1273,6 +1312,11 @@ pub async fn on_connect(_io: SocketIo, socket: SocketRef, Data(data): Data<Value
} }
if let Some(token) = data.get("token").and_then(|v| v.as_str()).filter(|v| !v.is_empty()) { if let Some(token) = data.get("token").and_then(|v| v.as_str()).filter(|v| !v.is_empty()) {
println!(
"[screen_game_score] cache auth token: userid={}, token_len={}",
userid,
token.len()
);
CLIENT_AUTH_TOKEN_MAP.insert(userid.clone(), token.to_string()); CLIENT_AUTH_TOKEN_MAP.insert(userid.clone(), token.to_string());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment