Skip to content

Commit

Permalink
Use async for HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
seionmoya committed Sep 9, 2024
1 parent b269b77 commit 43c676b
Show file tree
Hide file tree
Showing 79 changed files with 222 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ArenaServerListController() : base("/client/arena/server/list")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<ServerInfo[]>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public FriendListController() : base("/client/friend/list")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<FriendListResponse>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public FriendRequestListInboxController() : base("/client/friend/request/list/in
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<object[]>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public FriendRequestListOutboxController() : base("/client/friend/request/list/o
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<object[]>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public GameConfigurationController() : base("/client/game/configuration")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<GameConfigResponse>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public GameKeepaliveController() : base("/client/game/keepalive")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<GameKeepaliveResponse>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public GameStartController() : base("/client/game/start")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<GameStartResponse>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public GameTokenIssueController() : base("/client/game/token/issue")
_response = Resx.GetText("eft", "database.client.game.token.issue.json");
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
SendJson(context, _response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public GameVersionValidateController() : base("/client/game/version/validate")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<object>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public MailDialogListController() : base("/client/mail/dialog/list")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<object[]>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public MatchGroupCurrentController() : base("/client/match/group/current")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<MatchGroupCurrentResponse>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public MatchGroupInviteCancelAllController() : base("/client/match/group/invite/
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<bool>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public MenuLocaleController() : base("/client/menu/locale/{languageId}")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var parameters = context.GetPathParameters(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public NotifierChannelCreateController() : base("/client/notifier/channel/create
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var channelId = SimpleId.Generate(64);
var response = new ResponseBody<NotifierChannelCreateResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ProfileStatusController() : base("/client/profile/status")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var sessionId = context.GetSessionId();
var account = ArenaOrm.GetAccount(sessionId);
Expand Down
9 changes: 5 additions & 4 deletions Fuyu.Backend.Core/Controllers/AccountLoginController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Fuyu.Backend.Core.DTO.Requests;
using System.Threading.Tasks;
using Fuyu.Common.Networking;
using Fuyu.Common.Serialization;
using Fuyu.Backend.Core.DTO.Requests;
using Fuyu.Backend.Core.Services;

namespace Fuyu.Backend.Core.Controllers
Expand All @@ -11,12 +12,12 @@ public AccountLoginController() : base("/account/login")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var request = context.GetJson<AccountLoginRequest>();
var request = await context.GetJsonAsync<AccountLoginRequest>();
var response = AccountService.LoginAccount(request.Username, request.Password);

context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
7 changes: 4 additions & 3 deletions Fuyu.Backend.Core/Controllers/AccountRegisterController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Backend.Core.DTO.Requests;
using Fuyu.Backend.Core.DTO.Responses;
using Fuyu.Common.Networking;
Expand All @@ -12,16 +13,16 @@ public AccountRegisterController() : base("/account/register")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var request = context.GetJson<AccountRegisterRequest>();
var request = await context.GetJsonAsync<AccountRegisterRequest>();
var result = AccountService.RegisterAccount(request.Username, request.Password);
var response = new AccountRegisterResponse()
{
Status = result
};

context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Backend.Core.DTO.Requests;
using Fuyu.Backend.Core.DTO.Responses;
using Fuyu.Common.Networking;
Expand All @@ -12,17 +13,17 @@ public AccountRegisterGameController() : base("/account/register/game")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var request = context.GetJson<AccountRegisterGameRequest>();
var request = await context.GetJsonAsync<AccountRegisterGameRequest>();
var sessionId = context.GetSessionId();
var result = AccountService.RegisterGame(sessionId, request.Game, request.Edition);
var response = new AccountRegisterGameResponse()
{
Status = result
};

context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Common.Networking;

namespace Fuyu.Backend.EFT.Controllers
Expand All @@ -8,9 +9,9 @@ public AccountCustomizationController() : base("/client/account/customization")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
context.SendJson(EftOrm.GetAccountCustomization());
await context.SendJsonAsync(EftOrm.GetAccountCustomization());
}
}
}
5 changes: 3 additions & 2 deletions Fuyu.Backend.EFT/Controllers/AchievementListController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Common.Networking;

namespace Fuyu.Backend.EFT.Controllers
Expand All @@ -8,9 +9,9 @@ public AchievementListController() : base("/client/achievement/list")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
context.SendJson(EftOrm.GetAchievementList());
await context.SendJsonAsync(EftOrm.GetAchievementList());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Common.IO;
using Fuyu.Common.Networking;
using Fuyu.Common.Serialization;
Expand All @@ -12,11 +13,11 @@ public AchievementStatisticController() : base("/client/achievement/statistic")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var json = EftOrm.GetAchievementStatistic();
var response = Json.Parse<ResponseBody<AchievementStatisticResponse>>(json);
context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
5 changes: 3 additions & 2 deletions Fuyu.Backend.EFT/Controllers/BuildsListController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Common.IO;
using Fuyu.Common.Networking;
using Fuyu.Common.Serialization;
Expand All @@ -16,9 +17,9 @@ public BuildsListController() : base("/client/builds/list")
_response = Json.Parse<ResponseBody<BuildsListResponse>>(json);
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
context.SendJson(Json.Stringify(_response));
await context.SendJsonAsync(Json.Stringify(_response));
}
}
}
5 changes: 3 additions & 2 deletions Fuyu.Backend.EFT/Controllers/CheckVersionController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Common.Networking;
using Fuyu.Common.Serialization;
using Fuyu.Backend.BSG.DTO.Responses;
Expand All @@ -11,7 +12,7 @@ public CheckVersionController() : base("/client/checkVersion")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<CheckVersionResponse>()
{
Expand All @@ -22,7 +23,7 @@ public override void Run(HttpContext context)
}
};

context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
5 changes: 3 additions & 2 deletions Fuyu.Backend.EFT/Controllers/CustomizationController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using Fuyu.Common.Networking;
using Fuyu.Common.Serialization;
Expand All @@ -12,15 +13,15 @@ public CustomizationController() : base("/client/customization")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var customizations = EftOrm.GetCustomizations();
var response = new ResponseBody<Dictionary<string, CustomizationTemplate>>()
{
data = customizations
};

context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Common.Networking;
using Fuyu.Common.Serialization;
using Fuyu.Backend.BSG.DTO.Responses;
Expand All @@ -11,7 +12,7 @@ public CustomizationStorageController() : base("/client/trading/customization/st
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var sessionId = context.GetSessionId();
var account = EftOrm.GetAccount(sessionId);
Expand All @@ -30,7 +31,7 @@ public override void Run(HttpContext context)
}
};

context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
5 changes: 3 additions & 2 deletions Fuyu.Backend.EFT/Controllers/FriendListController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Fuyu.Common.Networking;
using Fuyu.Common.Serialization;
using Fuyu.Backend.BSG.DTO.Responses;
Expand All @@ -11,7 +12,7 @@ public FriendListController() : base("/client/friend/list")
{
}

public override void Run(HttpContext context)
public override async Task RunAsync(HttpContext context)
{
var response = new ResponseBody<FriendListResponse>()
{
Expand All @@ -23,7 +24,7 @@ public override void Run(HttpContext context)
}
};

context.SendJson(Json.Stringify(response));
await context.SendJsonAsync(Json.Stringify(response));
}
}
}
Loading

0 comments on commit 43c676b

Please sign in to comment.