TigerEmu/Communication/Messages/Incoming/Users/GetExtendedProfileEvent.cs

42 lines
1.3 KiB
C#

using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing.Users;
using Tiger.Communication.Messages.Types;
using Tiger.Game.Habbos;
using Tiger.Networking.Game.Sessions;
using Tiger.Storage;
namespace Tiger.Communication.Messages.Incoming.Users;
public class GetExtendedProfileEvent : IMessageEvent
{
private readonly IGameSessionManager _gameSessionManager;
private readonly IRepository<Habbo> _habboRepository;
public GetExtendedProfileEvent(IGameSessionManager gameSessionManager, IRepository<Habbo> habboRepository)
{
_gameSessionManager = gameSessionManager;
_habboRepository = habboRepository;
}
public IncomingHeaders Header => IncomingHeaders.GetExtendedProfileEvent;
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
{
var habboId = request.ReadInt32();
if (habboId == null)
{
await _gameSessionManager.CloseAsync("Malformed packet", gameSession);
return;
}
var habbo = await _habboRepository.FindAsync(habboId);
if (habbo == null)
{
await _gameSessionManager.CloseAsync("Habbo not found", gameSession);
return;
}
await gameSession.SendComposerAsync(new ExtendedProfileComposer(habbo));
}
}