/// <summary> /// Disconnection handler /// </summary> public void Disconnect() { if (!Authenticated) { return; } if (RoomEntity.Room != null) { RoomEntity.Room.EntityManager.LeaveRoom(this); } PlayerManager.Instance.RemovePlayer(this); Messenger.SendStatus(); Subscription.CountMemberDays(); playerData.LastOnline = DateTime.Now; UserDao.SaveLastOnline(playerData); long timeInSeconds = (long)(DateTime.Now - AuthenticationTime).TotalSeconds; settings.OnlineTime += timeInSeconds; UserSettingsDao.Update(settings); }
/// <summary> /// Login handler /// </summary> /// <param name="ssoTicket">the sso ticket</param> /// <returns></returns> public bool TryLogin(string ssoTicket) { UserDao.Login(out playerData, ssoTicket); if (playerData == null) { return(false); } log = LogManager.GetLogger(Assembly.GetExecutingAssembly(), $"Player {playerData.Name}"); log.Debug($"Player {playerData.Name} has logged in"); UserSettingsDao.CreateOrUpdate(out settings, playerData.Id); PlayerManager.Instance.AddPlayer(this); playerData.PreviousLastOnline = playerData.LastOnline; playerData.LastOnline = DateTime.Now; UserDao.Update(playerData); Subscription = SubscriptionDao.GetSubscription(playerData.Id); Messenger = new Messenger(this); Messenger.SendStatus(); Authenticated = true; Send(new AuthenticationOKComposer()); Send(new ActivityPointNotificationComposer()); Send(new AvailabilityStatusComposer()); Send(new UserRightsMessageComposer(IsSubscribed ? 2 : 0, playerData.Rank)); return(true); }
/// <summary> /// Login handler /// </summary> /// <param name="ssoTicket">the sso ticket</param> /// <returns></returns> public bool TryLogin(string ssoTicket) { UserDao.Login(out playerData, ssoTicket); if (playerData == null) { return(false); } log = LogManager.GetLogger(Assembly.GetExecutingAssembly(), $"Player {playerData.Name}"); log.Debug($"Player {playerData.Name} has logged in"); UserSettingsDao.CreateOrUpdate(out settings, playerData.Id); playerData.PreviousLastOnline = playerData.LastOnline; playerData.LastOnline = DateTime.Now; UserDao.SaveLastOnline(playerData); PlayerManager.Instance.AddPlayer(this); Subscription = new Subscription(this); Subscription.Load(); Subscription.CountMemberDays(); Currency = new CurrencyManager(this); Currency.Load(); Inventory = new Inventory(this); Inventory.Load(); Messenger = new Messenger(this); Messenger.SendStatus(); EffectManager = new EffectManager(this); EffectManager.Load(); Authenticated = true; AuthenticationTime = DateTime.Now; Send(new AuthenticationOKComposer()); Send(new AvailabilityStatusComposer()); Send(new UserRightsMessageComposer(IsSubscribed ? 2 : 0, UserGroup.HasPermission("room.addstaffpicks") ? 7 : playerData.Rank)); return(true); }