示例#1
0
 private void OnClientStarted(Client client)
 {
     Application.ClientStarted -= OnClientStarted;
     Application.RunTimeout (1000, delegate {
         startup_job.Finish ();
         return false;
     });
 }
 private void ReloadAllSources (Client client)
 {
     Application.ClientStarted -= ReloadAllSources;
     foreach (Source source in ServiceManager.SourceManager.Sources) {
         if (source is ITrackModelSource) {
             ((ITrackModelSource)source).Reload ();
         }
     }
 }
        private void Initialize (Client client)
        {
            Application.ClientStarted -= Initialize;

            var handler = Started;
            if (handler != null) {
                handler ();
            }

            Application.RunTimeout (5*1000, delegate {
                if (BansheeMetrics.Instance == null) {
                    return false;
                }

                metrics.AddDefaults ();
                AddMetrics ();

                ThreadAssist.SpawnFromMain (delegate {
                    if (ApplicationContext.CommandLine.Contains ("debug-metrics")) {
                        Log.InformationFormat ("Anonymous usage data collected:\n{0}", metrics.ToJsonString ());
                        System.IO.File.WriteAllText ("usage-data.json", metrics.ToJsonString ());
                    }

                    // Don't post to server more than every 48 hours
                    var last_post_time = DatabaseConfigurationClient.Client.Get<DateTime> (last_post_key, DateTime.MinValue);
                    var last_post_rel = (DateTime.Now - last_post_time).TotalHours;
                    if (last_post_rel < 0 || last_post_rel > 48.0) {
                        var poster = new HttpPoster ("http://metrics.banshee.fm/submit/", metrics);
                        bool posted = poster.Post ();
                        Log.InformationFormat ("Posted usage data? {0}", posted);
                        if (posted) {
                            metrics.Store.Clear ();
                            DatabaseConfigurationClient.Client.Set<DateTime> (last_post_key, DateTime.Now);
                        }
                    }
                });
                return false;
            });
        }
示例#4
0
 private static void OnClientStarted (Client client)
 {
     client.Started -= OnClientStarted;
     Action<Client> handler = client_started;
     if (handler != null) {
         handler (client);
     }
 }
示例#5
0
        public static void PushClient (Client client)
        {
            lock (running_clients) {
                running_clients.Push (client);
                client.Started += OnClientStarted;
            }

            Action<Client> handler = ClientAdded;
            if (handler != null) {
                handler (client);
            }
        }
示例#6
0
        private void Initialize (Client client)
        {
            Application.ClientStarted -= Initialize;

            var handler = Started;
            if (handler != null) {
                handler ();
            }

            Application.RunTimeout (5*1000, delegate {
                if (BansheeMetrics.Instance == null) {
                    return false;
                }

                ThreadAssist.SpawnFromMain (delegate {
                    metrics.AddDefaults ();
                    AddMetrics ();

                    if (ApplicationContext.CommandLine.Contains ("debug-metrics")) {
                        Log.InformationFormat ("Anonymous usage data collected:\n{0}", metrics.ToJsonString ());
                        System.IO.File.WriteAllText ("usage-data.json", metrics.ToJsonString ());
                    }

                    if (!ServiceManager.Get<Network> ().Connected) {
                        return;
                    }

                    // Don't post to server more than every 48 hours
                    var last_post_time = DatabaseConfigurationClient.Client.Get<DateTime> (last_post_key, DateTime.MinValue);
                    var last_post_rel = (DateTime.Now - last_post_time).TotalDays;
                    if (last_post_rel < 0 || last_post_rel > 4.0) {
                        var poster = new HttpPoster ("http://metrics.banshee.fm/submit/", metrics);
                        bool posted = poster.Post ();
                        Log.InformationFormat ("Posted usage data? {0}", posted);

                        // Clear the old metrics, even if we failed to post them; it might be a server-side
                        // problem w/ the data we want to send (eg too big, out of space) and we don't want
                        // to keep retrying to send the same data.
                        metrics.Store.Clear ();
                        DatabaseConfigurationClient.Client.Set<DateTime> (last_post_key, DateTime.Now);
                    }
                });

                return false;
            });
        }