From 29637ccee3e6e16c8573d9bd6c6ed57d730fe735 Mon Sep 17 00:00:00 2001 From: xiangmy21 <90919434+xiangmy21@users.noreply.github.com> Date: Wed, 8 May 2024 02:42:50 +0800 Subject: [PATCH 1/3] Update run.sh --- dependency/shell/run.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dependency/shell/run.sh b/dependency/shell/run.sh index 89f35a3e..bb10d6d1 100644 --- a/dependency/shell/run.sh +++ b/dependency/shell/run.sh @@ -64,11 +64,11 @@ function retry_command { sleep $sleep_seconds if kill -0 $PID 2>/dev/null; then - echo "Connected to server successfully." - return 0 - else echo "Failed to connect to server. Retrying..." ((attempt_num++)) + else + echo "Connected to server successfully." + return 0 fi done @@ -106,6 +106,7 @@ if [ "$TERMINAL" = "SERVER" ]; then finish_payload='{"result": {"status": "Crashed", "scores": [0, 0]}}' curl $FINISH_URL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d "${finish_payload}" > $playback_dir/send.log 2>&1 else + echo "Game is started." ps -p $server_pid while [ $? -eq 0 ] do From df66e5d4f863447c7907b642ffc4290654a6e19d Mon Sep 17 00:00:00 2001 From: xiangmy21 <90919434+xiangmy21@users.noreply.github.com> Date: Wed, 8 May 2024 03:28:41 +0800 Subject: [PATCH 2/3] Merge (#320) * Update run.sh * Update HttpSender.cs --- logic/Server/HttpSender.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/logic/Server/HttpSender.cs b/logic/Server/HttpSender.cs index 728e627a..c9652b5d 100755 --- a/logic/Server/HttpSender.cs +++ b/logic/Server/HttpSender.cs @@ -58,9 +58,8 @@ public async Task GetLadderScore(double[] scores) var jsonString = await response.Content.ReadAsStringAsync(); // 解析 JSON 字符串 - var result = JsonConvert.DeserializeObject>(jsonString); - double[] org = (from r in result select (double)(r.score)).ToArray(); - return org; + var result = JsonConvert.DeserializeObject(jsonString); + return result.Scores.Select(score => (double)score).ToArray();; } catch (Exception e) { From 87f7b707463f2ac18a271f2ad3525c6ed7e18e39 Mon Sep 17 00:00:00 2001 From: xiangmy21 <90919434+xiangmy21@users.noreply.github.com> Date: Wed, 8 May 2024 03:40:42 +0800 Subject: [PATCH 3/3] fix(http): ContestResult type (#321) * Update run.sh * Update HttpSender.cs * fix(http): ContestResult type --- logic/Server/GameServer.cs | 3 ++- logic/Server/HttpSender.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index acee6f86..35292541 100755 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -15,7 +15,8 @@ namespace Server { public class ContestResult { - public int score; + public string status; + public int[] scores; } partial class GameServer : ServerBase { diff --git a/logic/Server/HttpSender.cs b/logic/Server/HttpSender.cs index c9652b5d..8c3e6db1 100755 --- a/logic/Server/HttpSender.cs +++ b/logic/Server/HttpSender.cs @@ -58,8 +58,8 @@ public async Task GetLadderScore(double[] scores) var jsonString = await response.Content.ReadAsStringAsync(); // 解析 JSON 字符串 - var result = JsonConvert.DeserializeObject(jsonString); - return result.Scores.Select(score => (double)score).ToArray();; + var result = JsonConvert.DeserializeObject(jsonString); + return result.Scores.Select(score => (double)score).ToArray(); } catch (Exception e) {