40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using Tiger.Communication.Messages.Interfaces;
|
|
using Tiger.Communication.Messages.Outgoing.Catalog;
|
|
using Tiger.Communication.Messages.Types;
|
|
using Tiger.Game.Catalogue;
|
|
using Tiger.Networking.Game.Sessions;
|
|
|
|
namespace Tiger.Communication.Messages.Incoming.Catalog;
|
|
|
|
public class GetCatalogPageEvent : IMessageEvent
|
|
{
|
|
private readonly ICatalogueManager _catalogueManager;
|
|
private readonly IGameSessionManager _gameSessionManager;
|
|
|
|
public GetCatalogPageEvent(ICatalogueManager catalogueManager, IGameSessionManager gameSessionManager)
|
|
{
|
|
_catalogueManager = catalogueManager;
|
|
_gameSessionManager = gameSessionManager;
|
|
}
|
|
|
|
public IncomingHeaders Header => IncomingHeaders.GetCatalogPageEvent;
|
|
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
|
|
{
|
|
if (gameSession.Habbo == null)
|
|
{
|
|
await _gameSessionManager.CloseAsync("Not logged in", gameSession);
|
|
return;
|
|
}
|
|
|
|
var pageId = request.ReadInt32() ?? -1;
|
|
var offerId = request.ReadInt32() ?? 0;
|
|
var mode = request.ReadString() ?? "normal";
|
|
|
|
if (!_catalogueManager.Pages.TryGetValue(pageId, out var page))
|
|
{
|
|
return;
|
|
}
|
|
|
|
await gameSession.SendComposerAsync(new CatalogPageMessageComposer(page, offerId, mode));
|
|
}
|
|
} |