TigerEmu/Communication/Messages/Incoming/User/Data/UserProfileEvent.cs

30 lines
1019 B
C#

using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing.User.Data;
using Tiger.Communication.Messages.Types;
using Tiger.Game.Habbos;
using Tiger.Networking.Game.Sessions;
using Tiger.Storage;
namespace Tiger.Communication.Messages.Incoming.User.Data;
public class UserProfileEvent : IMessageEvent
{
private readonly IGameSessionManager _gameSessionManager;
private readonly IRepository<Habbo> _habboRepository;
public UserProfileEvent(IGameSessionManager gameSessionManager, IRepository<Habbo> habboRepository)
{
_gameSessionManager = gameSessionManager;
_habboRepository = habboRepository;
}
public IncomingHeaders Header => IncomingHeaders.UserProfile;
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
{
var habbo = await _habboRepository.FindAsync(request.ReadInt32());
if (habbo == null) return;
await gameSession.SendComposerAsync(new UserProfileComposer(habbo));
}
}