internal static void Update(BubbleGroup group, bool optimized = true, Action optimizedChainFinished = null) { if (optimized) { UpdateName(@group, () => { UpdateGroupLegibleID(@group, () => { UpdatePartyParticipants(@group, () => { if (optimizedChainFinished != null) { optimizedChainFinished(); } else { BubbleGroupEvents.RaiseRefreshed(@group); BubbleGroupEvents.RaiseBubblesUpdated(@group); BubbleGroupEvents.RaiseInformationUpdated(@group); } }); }); }); } else { UpdateName(@group); UpdateGroupLegibleID(@group); UpdatePartyParticipants(@group); } }
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); } }
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); } }
internal static async void UpdateName(BubbleGroup bubbleGroup, Action finished = null) { var service = bubbleGroup.Service; if (!ServiceManager.IsRunning(service)) { return; } try { await service.GetBubbleGroupName(bubbleGroup, title => { bubbleGroup.IsTitleSetFromService = true; if (string.IsNullOrWhiteSpace(title)) { Utils.DebugPrint("Update name title is null (rejecting): " + service.Information.ServiceName + " - " + bubbleGroup.Address); } else { bubbleGroup.Title = title; } if (finished == null) { BubbleGroupEvents.RaiseRefreshed(bubbleGroup); BubbleGroupEvents.RaiseInformationUpdated(bubbleGroup); } else { finished(); } }); } catch (Exception ex) { Utils.DebugPrint("Error updating bubble group name: " + service.Information.ServiceName + " - " + bubbleGroup.Address + ": " + ex); if (finished != null) { finished(); } } }
public static void Update(Service service, bool optimized = true) { const int Interval = 5; var updateCounter = 0; var groupsDoneCounter = 0; var groups = BubbleGroupManager.FindAll(service); var updateCounterThreshold = groups.Count / Interval; foreach (var group in groups) { Action chainFinished = null; if (groups.Count >= Interval) { chainFinished = () => { Action <bool> doUpdate = singleton => { BubbleGroupEvents.RaiseRefreshed(groups); BubbleGroupEvents.RaiseBubblesUpdated(groups); BubbleGroupEvents.RaiseInformationUpdated(groups); }; groupsDoneCounter++; if (groupsDoneCounter % Interval == 0) { updateCounter++; doUpdate(false); } // do the remainder one by one ... else if (updateCounter >= updateCounterThreshold) { doUpdate(true); } }; } Update(@group, optimized, chainFinished); } }
internal static void UpdateName(BubbleGroup bubbleGroup, Action finished = null) { var service = bubbleGroup.Service; if (!ServiceManager.IsRunning(service)) { return; } try { service.GetBubbleGroupName(bubbleGroup, title => { bubbleGroup.IsTitleSetFromService = true; bubbleGroup.Title = title; if (finished == null) { BubbleGroupEvents.RaiseRefreshed(bubbleGroup); BubbleGroupEvents.RaiseInformationUpdated(bubbleGroup); } else { finished(); } }); } catch (Exception ex) { Utils.DebugPrint("Error updating bubble group name: " + service.Information.ServiceName + ": " + ex.Message); if (finished != null) { finished(); } } }