Locator.Get.UpdateSlow.Subscribe(UpdateLobby,0.5f);// Shouldn't need to unsubscribe since this instance won't be replaced. 0.5s is arbitrary; the rate limits are tracked later.
m_pendingOperations.Dequeue()?.Invoke();// Note: If this ends up enqueuing a bunch of operations, we might need to batch them and/or ensure they don't all execute at once.
}
#endregion
/// Used for getting the list of all active lobbies, without needing full info for each.
/// </summary>
/// <param name="onListRetrieved">If called with null, retrieval was unsuccessful. Else, this will be given a list of contents to display, as pairs of a lobby code and a display string for that lobby.</param>
/// <param name="isRecursive">Just as a backup to effectively batch together multiple retrievals into one if they arrive in rapid succession.</param>
// We assume this can only occur when leaving a lobby and returning to the join menu; the refresh button is rate-limited, but we might have recently queried while still in the lobby.
if(!isRecursive)
{
m_pendingOperations.Enqueue(()=>{RetrieveLobbyListAsync(onListRetrieved,onError,limitToColor,true);});// With that assumption, retry the refresh after the limit, as though entering the join menu from the main menu.
privateboolm_isHandlingPending=false;// Just in case a pending operation tries to enqueue itself again.
publicvoidEnqueuePendingOperation(Actionaction)
{
if(!m_isHandlingPending)
m_pendingOperations.Enqueue(action);
}
privateboolm_isInCooldown=false;
publicboolIsInCooldown
privatevoidOnUpdate(floatdt)
{
m_timeSinceLastCall+=dt;
m_isHandlingPending=false;// (Backup in case a pending operation hit an exception.)
{
m_isHandlingPending=true;
while(m_pendingOperations.Count>0)
m_pendingOperations.Dequeue()?.Invoke();// Note: If this ends up enqueuing many operations, we might need to batch them and/or ensure they don't all execute at once.