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 _habboRepository; public UserProfileEvent(IGameSessionManager gameSessionManager, IRepository habboRepository) { _gameSessionManager = gameSessionManager; _habboRepository = habboRepository; } public IncomingHeaders Header => IncomingHeaders.UserProfile; 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 UserProfileComposer(habbo)); } }