using Tiger.Communication.Messages.Interfaces; using Tiger.Communication.Messages.Outgoing.Generic.Alerts; using Tiger.Communication.Messages.Outgoing.Handshake; using Tiger.Communication.Messages.Types; using Tiger.Game.Habbos; using Tiger.Game.Settings; using Tiger.Networking.Game.Sessions; namespace Tiger.Communication.Messages.Incoming.Handshake; public class SsoTicketEvent : IMessageEvent { private readonly IHabboDao _habboDao; private readonly IGameSessionManager _gameSessionManager; private readonly ISettingsManager _settingsManager; public SsoTicketEvent(IHabboDao habboDao, IGameSessionManager gameSessionManager, ISettingsManager settingsManager) { _habboDao = habboDao; _gameSessionManager = gameSessionManager; _settingsManager = settingsManager; } public IncomingHeaders Header => IncomingHeaders.SSoTicketEvent; public async Task HandleAsync(GameSession gameSession, ClientMessage request) { var sso = request.ReadString(); if (sso == null) { await _gameSessionManager.CloseAsync("Malformed packet", gameSession); return; } var habbo = await _habboDao.GetHabboBySsoAsync(sso); if (habbo == null) { await _gameSessionManager.CloseAsync("User not found", gameSession); return; } gameSession.Habbo = habbo; await gameSession.SendComposerAsync(new AuthenticationOkMessageComposer()); await gameSession.SendComposerAsync(new HabboBroadcastMessageComposer( _settingsManager.GetSetting("welcome.message") .Replace("{user}", gameSession.Habbo.Username) )); } }