chore: remove ConfigureAwait
This commit is contained in:
parent
f09ab06066
commit
bccbaa87d9
6 changed files with 35 additions and 38 deletions
|
@ -1,4 +1,4 @@
|
|||
// // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
// // Copyright (c) 2023 Timothy Schenk.Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetCoreServer;
|
||||
|
@ -26,7 +26,7 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
var guildNameResponsePacket = new CharacterSelectionSetGuildNamePacket { GuildNames = Array.Empty<string>() };
|
||||
|
||||
var account = await _wonderkingContext.Accounts
|
||||
.FirstOrDefaultAsync(a => a.Id == authSession.AccountId).ConfigureAwait(true);
|
||||
.FirstOrDefaultAsync(a => a.Id == authSession.AccountId);
|
||||
if (account != null && account.Characters.Count > 0)
|
||||
{
|
||||
responsePacket = new ChannelSelectionResponsePacket
|
||||
|
@ -55,13 +55,13 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
.Where(item => item.InventoryTab == InventoryTab.WornCashEquipment)
|
||||
.Select(item => new Tuple<ushort, byte>(item.ItemId, item.Slot)).AsEnumerable())
|
||||
})
|
||||
.ToArrayAsync().ConfigureAwait(true)
|
||||
.ToArrayAsync()
|
||||
};
|
||||
|
||||
guildNameResponsePacket.GuildNames = await _wonderkingContext.Characters
|
||||
.Where(c => c.Account.Id == authSession.AccountId)
|
||||
.Where(c => c.Guild != null)
|
||||
.Select(character => character.Guild.Name).ToArrayAsync().ConfigureAwait(true);
|
||||
.Select(character => character.Guild.Name).ToArrayAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -74,11 +74,11 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
};
|
||||
}
|
||||
|
||||
await authSession.SendAsync(responsePacket).ConfigureAwait(false);
|
||||
await authSession.SendAsync(responsePacket);
|
||||
if (guildNameResponsePacket.GuildNames.Length > 0 &&
|
||||
guildNameResponsePacket.GuildNames.Select(n => n != string.Empty).Any())
|
||||
{
|
||||
await authSession.SendAsync(guildNameResponsePacket).ConfigureAwait(false);
|
||||
await authSession.SendAsync(guildNameResponsePacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
// // Copyright (c) 2023 Timothy Schenk.Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetCoreServer;
|
||||
|
@ -43,7 +43,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
|
||||
var toBeAddedCharacter = CreateDefaultCharacter(packet, account, items, firstJobConfig);
|
||||
account?.Characters.Add(toBeAddedCharacter);
|
||||
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
await _wonderkingContext.SaveChangesAsync();
|
||||
|
||||
var character = await _wonderkingContext.Characters.AsNoTrackingWithIdentityResolution().AsSplitQuery()
|
||||
.Where(c => c.Account.Id == authSession.AccountId && c.Name == packet.Name)
|
||||
|
@ -65,13 +65,13 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
EquippedCashItems = GetItemIDsByInventoryTab(c.InventoryItems
|
||||
.Where(item => item.InventoryTab == InventoryTab.WornCashEquipment)
|
||||
.Select(item => new Tuple<ushort, byte>(item.ItemId, item.Slot)).AsEnumerable())
|
||||
}).FirstAsync().ConfigureAwait(true);
|
||||
}).FirstAsync();
|
||||
await authSession.SendAsync(new CharacterCreationResponsePacket
|
||||
{
|
||||
Character = character,
|
||||
Slot = packet.Slot,
|
||||
isDuplicate = false
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
private InventoryItem[] CreateDefaultItems(CharacterCreationPacket packet, JobSpecificMapping firstJobConfig)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
// // Copyright (c) 2023 Timothy Schenk.Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetCoreServer;
|
||||
|
@ -27,17 +27,17 @@ public class CharacterDeletionHandler : IPacketHandler<CharacterDeletePacket>
|
|||
|
||||
var character = await _wonderkingContext.Characters.FirstOrDefaultAsync(x => x.Name == packet.Name &&
|
||||
x.Account.Id == authSession.AccountId)
|
||||
.ConfigureAwait(true);
|
||||
;
|
||||
var response = new CharacterDeleteResponsePacket { IsDeleted = 0 };
|
||||
if (character == null)
|
||||
{
|
||||
await authSession.SendAsync(response).ConfigureAwait(false);
|
||||
await authSession.SendAsync(response);
|
||||
return;
|
||||
}
|
||||
|
||||
_wonderkingContext.Characters.Remove(character);
|
||||
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
await _wonderkingContext.SaveChangesAsync();
|
||||
|
||||
await authSession.SendAsync(response).ConfigureAwait(false);
|
||||
await authSession.SendAsync(response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
// // Copyright (c) 2023 Timothy Schenk.Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetCoreServer;
|
||||
using Server.DB;
|
||||
using Wonderking.Packets.Incoming;
|
||||
|
@ -16,15 +17,13 @@ public class CharacterNameCheckHandler : IPacketHandler<CharacterNameCheckPacket
|
|||
_wonderkingContext = wonderkingContext;
|
||||
}
|
||||
|
||||
public Task HandleAsync(CharacterNameCheckPacket packet, TcpSession session)
|
||||
public async Task HandleAsync(CharacterNameCheckPacket packet, TcpSession session)
|
||||
{
|
||||
var isTaken = _wonderkingContext.Characters.Any(c => c.Name == packet.Name);
|
||||
var isTaken = await _wonderkingContext.Characters.AnyAsync(c => c.Name == packet.Name);
|
||||
var responsePacket = new CharacterNameCheckPacketResponse { IsTaken = isTaken };
|
||||
if (session is AuthSession authSession)
|
||||
{
|
||||
return authSession.SendAsync(responsePacket);
|
||||
await authSession.SendAsync(responsePacket);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
// // Copyright (c) 2023 Timothy Schenk.Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
@ -34,14 +34,14 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
LoginResponseReason loginResponseReason;
|
||||
_logger.LoginData(packet.Username, packet.Password);
|
||||
var account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username)
|
||||
.ConfigureAwait(false);
|
||||
;
|
||||
|
||||
if (account == null)
|
||||
{
|
||||
if (_configuration.GetSection("Testing").GetValue<bool>("CreateAccountOnLogin"))
|
||||
{
|
||||
loginResponseReason = await CreateAccountOnLoginAsync(packet.Username, packet.Password)
|
||||
.ConfigureAwait(true);
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -52,8 +52,7 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
else
|
||||
{
|
||||
var salt = account.Salt;
|
||||
var tempPasswordBytes = await GetPasswordHashAsync(packet.Password, salt, account.Id)
|
||||
.ConfigureAwait(false);
|
||||
var tempPasswordBytes = await GetPasswordHashAsync(packet.Password, salt, account.Id);
|
||||
loginResponseReason = tempPasswordBytes.SequenceEqual(account.Password)
|
||||
? LoginResponseReason.Ok
|
||||
: LoginResponseReason.WrongPassword;
|
||||
|
@ -95,8 +94,8 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
{
|
||||
LoginResponseReason loginResponseReason;
|
||||
var transaction =
|
||||
await _wonderkingContext.Database.BeginTransactionAsync().ConfigureAwait(true);
|
||||
await using (transaction.ConfigureAwait(false))
|
||||
await _wonderkingContext.Database.BeginTransactionAsync();
|
||||
await using (transaction)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -104,20 +103,19 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
var finalAccount =
|
||||
await _wonderkingContext.Accounts.AddAsync(new Account(username,
|
||||
Array.Empty<byte>(), "",
|
||||
0, salt)).ConfigureAwait(true);
|
||||
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
0, salt));
|
||||
await _wonderkingContext.SaveChangesAsync();
|
||||
finalAccount.Entity.Password =
|
||||
await GetPasswordHashAsync(password, salt, finalAccount.Entity.Id)
|
||||
.ConfigureAwait(true);
|
||||
await GetPasswordHashAsync(password, salt, finalAccount.Entity.Id);
|
||||
_wonderkingContext.Accounts.Update(finalAccount.Entity);
|
||||
loginResponseReason = LoginResponseReason.Ok;
|
||||
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
await _wonderkingContext.SaveChangesAsync();
|
||||
|
||||
await transaction.CommitAsync().ConfigureAwait(true);
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await transaction.RollbackAsync().ConfigureAwait(true); // Rollback the transaction on error
|
||||
await transaction.RollbackAsync(); // Rollback the transaction on error
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
// // Copyright (c) 2023 Timothy Schenk.Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
@ -121,7 +121,7 @@ using var host = builder.Build();
|
|||
using (var scope = host.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<WonderkingContext>();
|
||||
await db.Database.MigrateAsync().ConfigureAwait(true);
|
||||
await db.Database.MigrateAsync();
|
||||
}
|
||||
|
||||
await host.RunAsync().ConfigureAwait(true);
|
||||
await host.RunAsync();
|
||||
|
|
Loading…
Reference in a new issue