Skip to content

Commit bf376d8

Browse files
committed
added http log
1 parent 483edb4 commit bf376d8

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

logic/Server/GameServer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ private void OnGameEnd()
403403
SaveGameResult(options.ResultFileName.EndsWith(".json")
404404
? options.ResultFileName
405405
: options.ResultFileName + ".json");
406+
GameServerLogging.logger.LogInfo($"OnGameEnd enters with mode={options.Mode}");
406407
int[] rawMatchScores = GetScore();
407408
double[] competitionScores = rawMatchScores.Select(x => (double)x).ToArray();
408409
if (options.Mode == 2)
@@ -416,9 +417,8 @@ private void OnGameEnd()
416417
}
417418
else
418419
rawMatchScores = ladderDeltas.Select(x => (int)x).ToArray();
419-
endGameSem.Release();
420-
Thread.Sleep(1);
421420
SendGameResult(rawMatchScores, gameCrashed);
421+
endGameSem.Release();
422422
}
423423
else if (options.Mode == 1)
424424
{
@@ -432,7 +432,6 @@ private void OnGameEnd()
432432
s = [2, 0];
433433
*/ // 得分计算方式待定
434434
endGameSem.Release();
435-
Thread.Sleep(1);
436435
//SendGameResult(s);
437436
}
438437
else

logic/Server/HttpSender.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,18 @@ public async Task SendHttpRequest(int[] scores, string state, string[][] player_
3838
scores,
3939
player_roles = player_role
4040
}));
41-
GameServerLogging.logger.LogInfo("Send to web successfully!");
42-
GameServerLogging.logger.LogInfo($"Web response: {await response.Content.ReadAsStringAsync()}");
41+
var body = await response.Content.ReadAsStringAsync();
42+
if (response.IsSuccessStatusCode)
43+
{
44+
GameServerLogging.logger.LogInfo("Send to web successfully!");
45+
GameServerLogging.logger.LogInfo($"Web response: {body}");
46+
}
47+
else
48+
{
49+
GameServerLogging.logger.LogWarning(
50+
$"Send to web failed with status {(int)response.StatusCode} {response.StatusCode}. Response: {body}"
51+
);
52+
}
4353
}
4454
catch (Exception e)
4555
{

0 commit comments

Comments
 (0)