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;
|
var authSession = (AuthSession)session;
|
||||||
ChannelSelectionResponsePacket responsePacket;
|
ChannelSelectionResponsePacket responsePacket;
|
||||||
var guildNameResponsePacket = new CharacterSelectionSetGuildNamePacket { GuildNames = Array.Empty<string>() };
|
var guildNameResponsePacket = new CharacterSelectionSetGuildNamePacket { GuildNames = Array.Empty<string>() };
|
||||||
|
|
||||||
var hasCharacters = this._wonderkingContext.Accounts.Include(account => account.Characters)
|
var account = await this._wonderkingContext.Accounts.Include(account => account.Characters)
|
||||||
.FirstOrDefault(a => a.Id == authSession.AccountId)?.Characters.Count > 0;
|
.FirstOrDefaultAsync(a => a.Id == authSession.AccountId).ConfigureAwait(true);
|
||||||
if (hasCharacters)
|
if (account != null && account.Characters.Count > 0)
|
||||||
{
|
{
|
||||||
responsePacket = new ChannelSelectionResponsePacket
|
responsePacket = new ChannelSelectionResponsePacket
|
||||||
{
|
{
|
||||||
ChannelIsFullFlag = 0,
|
ChannelIsFullFlag = 0,
|
||||||
Endpoint = "127.0.0.1",
|
Endpoint = "127.0.0.1",
|
||||||
Port = 12345,
|
Port = 12345,
|
||||||
Characters = this._wonderkingContext.Characters.AsNoTracking()
|
Characters = await _wonderkingContext.Characters.AsNoTracking()
|
||||||
.Where(c => c.Account.Id == authSession.AccountId)
|
.Where(c => c.Account.Id == authSession.AccountId)
|
||||||
.Select(c =>
|
.Select(c =>
|
||||||
new CharacterData
|
new CharacterData
|
||||||
|
@ -67,12 +67,12 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
||||||
.Select(item => item.ItemId)
|
.Select(item => item.ItemId)
|
||||||
.ToArray()
|
.ToArray()
|
||||||
})
|
})
|
||||||
.ToArray(),
|
.ToArrayAsync().ConfigureAwait(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
guildNameResponsePacket.GuildNames = this._wonderkingContext.Characters
|
guildNameResponsePacket.GuildNames = await _wonderkingContext.Characters
|
||||||
.Where(c => c.Account.Id == authSession.AccountId)
|
.Where(c => c.Account.Id == authSession.AccountId)
|
||||||
.Select(character => character.Guild.Name).ToArray();
|
.Select(character => character.Guild.Name).ToArrayAsync().ConfigureAwait(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,5 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
||||||
|
|
||||||
authSession.Send(responsePacket);
|
authSession.Send(responsePacket);
|
||||||
authSession.Send(guildNameResponsePacket);
|
authSession.Send(guildNameResponsePacket);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
||||||
_itemObjectPoolService = itemObjectPoolService;
|
_itemObjectPoolService = itemObjectPoolService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task HandleAsync(CharacterCreationPacket packet, TcpSession session)
|
public async Task HandleAsync(CharacterCreationPacket packet, TcpSession session)
|
||||||
{
|
{
|
||||||
var authSession = session as AuthSession;
|
var authSession = session as AuthSession;
|
||||||
var account =
|
var account =
|
||||||
|
@ -59,9 +59,9 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
||||||
Health = 250,
|
Health = 250,
|
||||||
Mana = 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)
|
.Where(c => authSession != null && c.Account.Id == authSession.AccountId && c.Name == packet.Name)
|
||||||
.Select(c =>
|
.Select(c =>
|
||||||
new CharacterData
|
new CharacterData
|
||||||
|
@ -82,8 +82,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
||||||
.Where(item => item.InventoryTab == InventoryTab.WornCashEquipment)
|
.Where(item => item.InventoryTab == InventoryTab.WornCashEquipment)
|
||||||
.Select(item => item.ItemId)
|
.Select(item => item.ItemId)
|
||||||
.ToArray(),
|
.ToArray(),
|
||||||
}).FirstOrDefault();
|
}).FirstOrDefaultAsync().ConfigureAwait(true);
|
||||||
authSession?.Send(new CharacterCreationResponsePacket { Character = character });
|
authSession?.Send(new CharacterCreationResponsePacket { Character = character });
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue