37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
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;
|
|
}
|
|
|
|
var viewName = request.ReadString();
|
|
var query = request.ReadString();
|
|
|
|
if (viewName is null || query is null ||
|
|
!_navigatorManager.NavigatorViews.TryGetValue(viewName, out var navigatorView)) return;
|
|
|
|
await gameSession.SendComposerAsync(new NavigatorSearchComposer(navigatorView, query, gameSession.Habbo));
|
|
}
|
|
} |