internal static void UpdateLastOnline(BubbleGroup bubbleGroup, bool updateUi = true, bool fromProcessUpdateLastOnlineQueue = false)
        {
            var service = bubbleGroup.Service;

            if (!fromProcessUpdateLastOnlineQueue)
            {
                if (!ServiceManager.IsRunning(service) && !bubbleGroup.IsParty)
                {
                    lock (UpdateLastOnlineQueue)
                        UpdateLastOnlineQueue.Add(new Tuple <BubbleGroup, bool>(bubbleGroup, updateUi));
                    return;
                }
            }

            if (!ServiceManager.IsRunning(service) || bubbleGroup.IsParty)
            {
                return;
            }

            // reject the last online update if the Presence is currently available
            if (bubbleGroup.Presence)
            {
                return;
            }

            try
            {
                service.GetBubbleGroupLastOnline(bubbleGroup, time =>
                {
                    // reject the last online update if the Presence is currently available
                    if (bubbleGroup.Presence)
                    {
                        return;
                    }

                    bubbleGroup.PresenceType = PresenceBubble.PresenceType.Unavailable;
                    bubbleGroup.LastSeen     = time;

                    if (updateUi)
                    {
                        BubbleGroupEvents.RaiseInformationUpdated(bubbleGroup);
                    }

                    //we constantly need to subscribe to a bubble group. doing it
                    //in last online method is the most effective.
                    BubbleManager.SendSubscribe(bubbleGroup, true);
                    //Presence(service, true);
                });
            }
            catch (Exception ex)
            {
                Utils.DebugPrint("Error updating bubble group last online: " + service.Information.ServiceName + ": " +
                                 ex.Message);
            }
        }
Esempio n. 2
0
        internal static void UpdateLastOnline(BubbleGroup bubbleGroup, bool updateUi = true, bool fromProcessUpdateLastOnlineQueue = false)
        {
            var service = bubbleGroup.Service;

            if (!fromProcessUpdateLastOnlineQueue)
            {
                if (!ServiceManager.IsRunning(service) && !bubbleGroup.IsParty)
                {
                    Utils.DebugPrint(">>>>>>>>>>>>>> Stashing UpdateLastOnline for later.");
                    lock (UpdateLastOnlineQueue)
                        UpdateLastOnlineQueue.Add(new Tuple <BubbleGroup, bool>(bubbleGroup, updateUi));
                    return;
                }
            }

            if (!ServiceManager.IsRunning(service) || bubbleGroup.IsParty)
            {
                return;
            }

            // reject the last online update if the Presence is currently available
            if (bubbleGroup.Presence)
            {
                return;
            }

            try
            {
                Utils.DebugPrint(">>>>>>>>>>>>>> Calling GetBubbleGroupLastOnline.");
                service.GetBubbleGroupLastOnline(bubbleGroup, time =>
                {
                    // reject the last online update if the Presence is currently available
                    if (bubbleGroup.Presence)
                    {
                        return;
                    }

                    bubbleGroup.PresenceType = PresenceBubble.PresenceType.Unavailable;
                    bubbleGroup.LastSeen     = time;

                    if (updateUi)
                    {
                        BubbleGroupEvents.RaiseInformationUpdated(bubbleGroup);
                    }
                });
            }
            catch (Exception ex)
            {
                Utils.DebugPrint("Error updating bubble group last online: " + service.Information.ServiceName + ": " +
                                 ex.Message);
            }
        }
Esempio n. 3
0
 public static Task ProcessUpdateLastOnlineQueue(Service service)
 {
     return(Task.Factory.StartNew(() =>
     {
         lock (UpdateLastOnlineQueue)
         {
             foreach (var updateLastOnlineTuple in
                      UpdateLastOnlineQueue.Where(x => x.Item1.Service == service).ToList())
             {
                 UpdateLastOnline(updateLastOnlineTuple.Item1, updateLastOnlineTuple.Item2, true);
                 UpdateLastOnlineQueue.Remove(updateLastOnlineTuple);
             }
         }
     }));
 }
Esempio n. 4
0
 public static Task ProcessUpdateLastOnlineQueue(Service service)
 {
     return(Task.Factory.StartNew(() =>
     {
         lock (UpdateLastOnlineQueue)
         {
             Utils.DebugPrint(">>>>>>>>>>>>>> Processing all last online times...");
             foreach (var updateLastOnlineTuple in
                      UpdateLastOnlineQueue.Where(x => x.Item1.Service == service).ToList())
             {
                 Utils.DebugPrint(">>>>>>>>>>>>>> Processing last online time (from stash) for service: " + service.Information.ServiceName);
                 UpdateLastOnline(updateLastOnlineTuple.Item1, updateLastOnlineTuple.Item2, true);
                 UpdateLastOnlineQueue.Remove(updateLastOnlineTuple);
             }
         }
     }));
 }