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

32 lines
1021 B
C#

using FluentNHibernate.Conventions;
using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing.Navigator;
using Tiger.Communication.Messages.Types;
using Tiger.Networking.Game.Sessions;
namespace Tiger.Communication.Messages.Incoming.Navigator;
public class SearchUserFlatsEvent : IMessageEvent
{
public IncomingHeaders Header => IncomingHeaders.Suserf;
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
{
if (gameSession.Habbo == null)
{
await gameSession.CloseAsync();
return;
}
if (gameSession.Habbo.Rooms.IsEmpty())
{
await gameSession.SendComposerAsync(new NoFlatsForUserComposer());
}
else
{
await gameSession.SendComposerAsync(
new FlatResultsComposer(
FlatResultsComposer.UserFlats,
gameSession.Habbo.Rooms.OrderByDescending(r => r.UsersIn).ToList()));
}
}
}