/// <summary> /// Constructor /// </summary> public ServerInfoResponse(ToucheeServer server, Library library) { DateTime now = DateTime.Now; this.Name = Medium.Local == null ? System.Environment.MachineName : Medium.Local.Name; this.WelcomeMessage = Program.Config.Get("welcomeMessage") ?? "Welcome to Touchee"; this.WebsocketPort = server.WebsocketPort; this.UtcTime = (long)now.TimeStamp(); this.UtcOffset = (long)TimeZone.CurrentTimeZone.GetUtcOffset(now).TotalMinutes; this.Devices = Device.All(); this.Plugins = PluginManager.FrontendPlugins.Select(p => p.GetType().Assembly.GetName().Name.ToUnderscore()).ToArray(); this.Revision = library.Revision; }
/// <summary> /// Initialises the library /// </summary> /// <param name="mediaWatcherPollingInterval">The interval at which to look for modified media</param> public void Init(ToucheeServer server, int mediaWatcherPollingInterval) { _server = server; // Set retry period from config int period = Program.Config.Get("artwork.retryPeriod") ?? 2592000; _artworkRetryPeriod = new TimeSpan(0, 0, period); // Instantiate all available MediumWatchers // These watch the Medium instances and generate Containers _mediumWatchers = PluginManager.GetComponent <IMediumWatcher>().ToList(); Medium.AfterCreate += Medium_AfterCreate; Medium.AfterDispose += Medium_BeforeDispose; // Watch for container changes Container.AfterSave += ContainersChanged; Container.AfterDispose += ContainersChanged; Container.ContentsChanged += ContainerContentsChanged; // Watch for device changes Device.AfterCreate += DevicesChanged; Device.AfterDispose += DevicesChanged; Device.AfterUpdate += DeviceChanged; // Init local and web media string localMediumName = Program.Config.Get("name", System.Environment.MachineName); LocalMedium.Init(localMediumName); string webCastsName = Program.Config.Get("webcastsName", "Webcasts"); WebMedium.Init(webCastsName); // Instantiate all available MediaWatchers // These generate Medium instances PluginManager.Register(new DriveMediaWatcher()); _mediaWatchers = PluginManager.GetComponent <IMediaWatcher>().ToList(); // Start media detection _mediaWatchers.ForEach(w => w.Watch(mediaWatcherPollingInterval)); }