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

41 lines
1.6 KiB
C#
Raw Normal View History

2023-10-14 20:32:12 +00:00
using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing;
2023-10-14 20:32:12 +00:00
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;
}
if (!_navigatorManager.NavigatorViews.TryGetValue(request.ReadString(), out var navigatorView)) return;
var qry = request.ReadString();
2023-10-14 20:32:12 +00:00
var message = new ServerMessage((short)OutgoingHeaders.NavigatorSearch);
message.AppendString(navigatorView.Code);
message.AppendString(qry);
await navigatorView.Compose(message, gameSession.Habbo, qry);
await gameSession.SendMessageAsync(message);
// await gameSession.SendComposerAsync(new NavigatorSearchComposer(navigatorView, request.ReadString(), gameSession.Habbo));
2023-10-14 20:32:12 +00:00
}
}