Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoWQ222 committed May 7, 2024
1 parent a39673a commit 37a485c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions logic/Server/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ partial class GameServer : ServerBase
private readonly ConcurrentDictionary<long, (SemaphoreSlim, SemaphoreSlim)> semaDict1 = new();
// private object semaDictLock = new();
protected readonly ArgumentOptions options;
private readonly HttpSender? httpSender;
private readonly HttpSender httpSender;
private readonly object gameLock = new();
private MessageToClient currentGameInfo = new();
private readonly MessageOfObj currentMapMsg = new();
Expand Down Expand Up @@ -220,7 +220,7 @@ private void OnGameEnd()
if (doubleArray.Length == 0)
{
crash = true;
Console.WriteLine("Error: No data returned from the web!");
GameServerLogging.logger.ConsoleLog("Error: No data returned from the web!");
}
else
scores = doubleArray.Select(x => (int)x).ToArray();
Expand Down
5 changes: 2 additions & 3 deletions logic/Server/HttpSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task SendHttpRequest(int[] scores, string state)
{
var request = new HttpClient();
request.DefaultRequestHeaders.Authorization = new("Bearer", token);
using var response = await request.PutAsync(url, JsonContent.Create(new
using var response = await request.PostAsync(url, JsonContent.Create(new
{
status = state,
scores = new int[] { scores[0], scores[1] },
Expand All @@ -48,12 +48,11 @@ public async Task SendHttpRequest(int[] scores, string state)

public async Task<double[]> GetLadderScore(double[] scores)
{

try
{
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", token);
var response = await httpClient.PostAsync(url, JsonContent.Create(new { HttpHeaders = token }));
var response = await httpClient.PostAsync(url, null);

// 读取响应内容为字符串
var jsonString = await response.Content.ReadAsStringAsync();
Expand Down

0 comments on commit 37a485c

Please sign in to comment.