2023-10-14 20:32:12 +00:00
|
|
|
using Tiger.Communication.Messages.Interfaces;
|
|
|
|
using Tiger.Communication.Messages.Outgoing.Navigator;
|
|
|
|
using Tiger.Communication.Messages.Types;
|
|
|
|
using Tiger.Game.Navigator;
|
|
|
|
using Tiger.Networking.Game.Sessions;
|
|
|
|
|
|
|
|
namespace Tiger.Communication.Messages.Incoming.Navigator;
|
|
|
|
|
|
|
|
public class NavigatorSearchEvent : IMessageEvent
|
|
|
|
{
|
|
|
|
private readonly IGameSessionManager _gameSessionManager;
|
|
|
|
private readonly INavigatorManager _navigatorManager;
|
|
|
|
|
|
|
|
public NavigatorSearchEvent(IGameSessionManager gameSessionManager, INavigatorManager navigatorManager)
|
|
|
|
{
|
|
|
|
_gameSessionManager = gameSessionManager;
|
|
|
|
_navigatorManager = navigatorManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IncomingHeaders Header => IncomingHeaders.NavigatorSearch;
|
|
|
|
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
|
|
|
|
{
|
|
|
|
if (gameSession.Habbo == null)
|
|
|
|
{
|
|
|
|
await _gameSessionManager.CloseAsync("Not logged in", gameSession);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-10-20 19:02:11 +00:00
|
|
|
if (!_navigatorManager.NavigatorViews.TryGetValue(request.ReadString(), out var navigatorView)) return;
|
2023-10-14 20:32:12 +00:00
|
|
|
|
2023-10-20 19:02:11 +00:00
|
|
|
await gameSession.SendComposerAsync(new NavigatorSearchComposer(navigatorView, request.ReadString(), gameSession.Habbo));
|
2023-10-14 20:32:12 +00:00
|
|
|
}
|
|
|
|
}
|