public VisitsUserAgentSubMenu(ISettingsProvider settingsProvider) { if (settingsProvider == null) { throw new ArgumentNullException(nameof(settingsProvider)); } UserSessionSettings settings = settingsProvider.GetSettings <UserSessionSettings>(Constants.UserSessionConfiguration); _enabled = settings.EnableDefaultSessionService; }
/// <summary> /// Default constructor /// </summary> /// <param name="hostingEnvironment">IHostingEnvironment instance</param> /// <param name="settingsProvider">ISettingsProvider instance</param> /// <param name="geoIpProvider">IGeoIpProvider instance</param> /// <param name="logger">ILogger instance</param> public DefaultUserSessionService(IHostingEnvironment hostingEnvironment, ISettingsProvider settingsProvider, IGeoIpProvider geoIpProvider, ILogger logger) : this() { if (hostingEnvironment == null) { throw new ArgumentNullException(nameof(hostingEnvironment)); } if (settingsProvider == null) { throw new ArgumentNullException(nameof(settingsProvider)); } _geoIpProvider = geoIpProvider ?? throw new ArgumentNullException(nameof(geoIpProvider)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); UserSessionSettings settings = settingsProvider.GetSettings <UserSessionSettings>(Constants.UserSessionConfiguration); if (!settings.EnableDefaultSessionService) { return; } _enabled = true; ContinueIfGlobalException = true; if (String.IsNullOrEmpty(settings.SessionRootPath)) { settings.SessionRootPath = hostingEnvironment.ContentRootPath; } _rootPath = Path.Combine(settings.SessionRootPath, "UserSession"); _activeSessionPath = GetPath("ActiveSessions"); _pageViewFile = GetFile(Path.Combine(_rootPath, "Sessions"), "PageViews.dat"); _referrerFile = GetFile(Path.Combine(_rootPath, "Sessions"), "InitialReferrer.dat"); _sessionHourlyFile = GetFile(Path.Combine(_rootPath, "Sessions"), "Hourly.dat"); _sessionDailyFile = GetFile(Path.Combine(_rootPath, "Sessions"), "Daily.dat"); _sessionWeeklyFile = GetFile(Path.Combine(_rootPath, "Sessions"), "Weekly.dat"); _sessionMonthlyFile = GetFile(Path.Combine(_rootPath, "Sessions"), "Monthly.dat"); _sessionYearlyFile = GetFile(Path.Combine(_rootPath, "Sessions"), "Yearly.dat"); _maxHours = settings.MaxHourlyData; _maxDays = settings.MaxDailyData; _maxWeeks = settings.MaxWeeklyData; _maxMonths = settings.MaxMonthlyData; _maxYears = settings.MaxYearlyData; LoadSessionData(_pageViewFile, ref _sessionPageViews); LoadSessionData(_referrerFile, ref _initialReferrers); LoadSessionData(_sessionHourlyFile, ref _hourlySessionData); LoadSessionData(_sessionDailyFile, ref _dailySessionData); LoadSessionData(_sessionWeeklyFile, ref _weeklySessionData); LoadSessionData(_sessionMonthlyFile, ref _monthlySessionData); LoadSessionData(_sessionYearlyFile, ref _yearlySessionData); ThreadManager.ThreadStart(this, "Default User Session Service", System.Threading.ThreadPriority.BelowNormal); }
/// <summary> /// UserSession constructor /// </summary> public UserSession(uint newSessionNumber) { SessionNumber = newSessionNumber; Client = new GridClient(); OpenMetaverse.Settings.LOG_LEVEL = Helpers.LogLevel.Error; Client.Settings.LOGIN_TIMEOUT = 480 * 1000; Client.Settings.SEND_AGENT_UPDATES = true; Client.Self.Movement.Camera.Far = 96.0f; Client.Self.Movement.Camera.AtAxis = Vector3.Zero; Client.Self.Movement.Camera.Position = Vector3.Zero; Client.Self.Movement.Camera.LeftAxis = Vector3.Zero; Client.Self.Movement.Camera.UpAxis = Vector3.Zero; Client.Self.Movement.HeadRotation = Quaternion.Identity; Client.Self.Movement.BodyRotation = Quaternion.Identity; Callbacks = new CallbackManager(this); Avatars = new Dictionary<uint, Avatar>(); Balance = -1; Friends = new Dictionary<UUID, Avatar>(); Groups = new Dictionary<UUID, OpenMetaverse.Group>(); IMSessions = new Dictionary<UUID, IMSession>(); Prims = new Dictionary<uint, Primitive>(); Timers = new Dictionary<string, ScriptSystem.UserTimer>(); Debug = 0; LastDialogChannel = -1; LastDialogID = UUID.Zero; MoneySpent = 0; MoneyReceived = 0; MasterIMSession = UUID.Zero; RegionX = 0; RegionY = 0; Settings = new UserSessionSettings(); StartTime = Utils.GetUnixTime(); FollowName = ""; FollowTimer = new System.Timers.Timer(500); FollowTimer.Enabled = false; FollowTimer.AutoReset = true; FollowTimer.Elapsed += new System.Timers.ElapsedEventHandler(FollowTimer_Elapsed); Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); }