TigerEmu/Communication/Messages/Incoming/Navigator/GetUserFlatCatsMessageEvent.cs

32 lines
1.1 KiB
C#

using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing.Navigator;
using Tiger.Communication.Messages.Types;
using Tiger.Game.Rooms;
using Tiger.Networking.Game.Sessions;
namespace Tiger.Communication.Messages.Incoming.Navigator;
public class GetUserFlatCatsMessageEvent : IMessageEvent
{
private readonly IGameSessionManager _gameSessionManager;
private readonly IRoomManager _roomManager;
public GetUserFlatCatsMessageEvent(IRoomManager roomManager, IGameSessionManager gameSessionManager)
{
_roomManager = roomManager;
_gameSessionManager = gameSessionManager;
}
public IncomingHeaders Header => IncomingHeaders.GetUserFlatCats;
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
{
if (gameSession.Habbo == null)
{
await _gameSessionManager.CloseAsync("Not logged in", gameSession);
return;
}
await gameSession.SendComposerAsync(new UserFlatCatsComposer(_roomManager.PrivateCategories.Values,
gameSession.Habbo.Rank));
}
}