2023-11-01 20:06:02 +00:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Wonderking.Packets.Incoming;
|
|
|
|
|
2023-10-12 07:15:34 +00:00
|
|
|
namespace Server.PacketHandlers;
|
2023-08-14 20:22:43 +00:00
|
|
|
|
|
|
|
using DB;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using NetCoreServer;
|
|
|
|
|
|
|
|
public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|
|
|
{
|
2023-11-01 17:18:27 +00:00
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
private readonly ILogger<ChannelSelectionHandler> _logger;
|
|
|
|
private readonly WonderkingContext _wonderkingContext;
|
2023-08-14 20:22:43 +00:00
|
|
|
|
|
|
|
public ChannelSelectionHandler(IConfiguration configuration, ILogger<ChannelSelectionHandler> logger,
|
|
|
|
WonderkingContext wonderkingContext)
|
|
|
|
{
|
2023-11-01 17:18:27 +00:00
|
|
|
this._configuration = configuration;
|
|
|
|
this._logger = logger;
|
|
|
|
this._wonderkingContext = wonderkingContext;
|
2023-08-14 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ChannelSelectionHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Task HandleAsync(ChannelSelectionPacket packet, TcpSession session)
|
|
|
|
{
|
|
|
|
var authSession = (AuthSession)session;
|
2023-11-01 20:06:02 +00:00
|
|
|
var charactersOfAccount = this._wonderkingContext.Accounts.Include(account => account.Characters)
|
|
|
|
.FirstOrDefault(a => a.Id == authSession.AccountId)
|
|
|
|
?.Characters;
|
2023-08-14 20:22:43 +00:00
|
|
|
return Task.CompletedTask;
|
|
|
|
}
|
|
|
|
}
|