refactor: make HandleAsync async
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 27s
Build, Package and Push Images / sonarqube (push) Has been skipped
Build, Package and Push Images / docs (push) Successful in 37s
Build, Package and Push Images / sbom-scan (push) Successful in 55s
Build, Package and Push Images / build-docs-container (push) Successful in 1m21s
Build, Package and Push Images / container-build (push) Successful in 1m29s
Build, Package and Push Images / deploy-wiki (push) Successful in 5s
Build, Package and Push Images / container-sbom-scan (push) Successful in 51s
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 27s
Build, Package and Push Images / sonarqube (push) Has been skipped
Build, Package and Push Images / docs (push) Successful in 37s
Build, Package and Push Images / sbom-scan (push) Successful in 55s
Build, Package and Push Images / build-docs-container (push) Successful in 1m21s
Build, Package and Push Images / container-build (push) Successful in 1m29s
Build, Package and Push Images / deploy-wiki (push) Successful in 5s
Build, Package and Push Images / container-sbom-scan (push) Successful in 51s
This commit is contained in:
parent
b68e058429
commit
5abe7f7564
2 changed files with 12 additions and 15 deletions
|
@ -29,22 +29,22 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
{
|
||||
}
|
||||
|
||||
public Task HandleAsync(ChannelSelectionPacket packet, TcpSession session)
|
||||
public async Task HandleAsync(ChannelSelectionPacket packet, TcpSession session)
|
||||
{
|
||||
var authSession = (AuthSession)session;
|
||||
ChannelSelectionResponsePacket responsePacket;
|
||||
var guildNameResponsePacket = new CharacterSelectionSetGuildNamePacket { GuildNames = Array.Empty<string>() };
|
||||
|
||||
var hasCharacters = this._wonderkingContext.Accounts.Include(account => account.Characters)
|
||||
.FirstOrDefault(a => a.Id == authSession.AccountId)?.Characters.Count > 0;
|
||||
if (hasCharacters)
|
||||
var account = await this._wonderkingContext.Accounts.Include(account => account.Characters)
|
||||
.FirstOrDefaultAsync(a => a.Id == authSession.AccountId).ConfigureAwait(true);
|
||||
if (account != null && account.Characters.Count > 0)
|
||||
{
|
||||
responsePacket = new ChannelSelectionResponsePacket
|
||||
{
|
||||
ChannelIsFullFlag = 0,
|
||||
Endpoint = "127.0.0.1",
|
||||
Port = 12345,
|
||||
Characters = this._wonderkingContext.Characters.AsNoTracking()
|
||||
Characters = await _wonderkingContext.Characters.AsNoTracking()
|
||||
.Where(c => c.Account.Id == authSession.AccountId)
|
||||
.Select(c =>
|
||||
new CharacterData
|
||||
|
@ -67,12 +67,12 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
.Select(item => item.ItemId)
|
||||
.ToArray()
|
||||
})
|
||||
.ToArray(),
|
||||
.ToArrayAsync().ConfigureAwait(true),
|
||||
};
|
||||
|
||||
guildNameResponsePacket.GuildNames = this._wonderkingContext.Characters
|
||||
guildNameResponsePacket.GuildNames = await _wonderkingContext.Characters
|
||||
.Where(c => c.Account.Id == authSession.AccountId)
|
||||
.Select(character => character.Guild.Name).ToArray();
|
||||
.Select(character => character.Guild.Name).ToArrayAsync().ConfigureAwait(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -87,7 +87,5 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
|
||||
authSession.Send(responsePacket);
|
||||
authSession.Send(guildNameResponsePacket);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
_itemObjectPoolService = itemObjectPoolService;
|
||||
}
|
||||
|
||||
public Task HandleAsync(CharacterCreationPacket packet, TcpSession session)
|
||||
public async Task HandleAsync(CharacterCreationPacket packet, TcpSession session)
|
||||
{
|
||||
var authSession = session as AuthSession;
|
||||
var account =
|
||||
|
@ -59,9 +59,9 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
Health = 250,
|
||||
Mana = 250,
|
||||
});
|
||||
_wonderkingContext.SaveChanges();
|
||||
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
|
||||
var character = this._wonderkingContext.Characters.AsNoTracking()
|
||||
var character = await _wonderkingContext.Characters.AsNoTracking()
|
||||
.Where(c => authSession != null && c.Account.Id == authSession.AccountId && c.Name == packet.Name)
|
||||
.Select(c =>
|
||||
new CharacterData
|
||||
|
@ -82,8 +82,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
.Where(item => item.InventoryTab == InventoryTab.WornCashEquipment)
|
||||
.Select(item => item.ItemId)
|
||||
.ToArray(),
|
||||
}).FirstOrDefault();
|
||||
}).FirstOrDefaultAsync().ConfigureAwait(true);
|
||||
authSession?.Send(new CharacterCreationResponsePacket { Character = character });
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue