using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// Temporary script to allow a user to delete all the rooms they've previously made, so we don't have orphaned empty rooms.
///
public class TempDeleteAllRooms : MonoBehaviour
{
private Queue m_pendingRooms;
public void OnButton()
{
LobbyRelaySample.Lobby.LobbyAPIInterface.QueryAllLobbiesAsync((qr) => { DoDeletes(qr); });
}
private void DoDeletes(Unity.Services.Rooms.Response response)
{
if (response != null && response.Status >= 200 && response.Status < 300)
{
StartCoroutine(DeleteCoroutine(response.Result.Results));
}
}
private IEnumerator DeleteCoroutine(List rooms)
{
foreach (var room in rooms)
{
LobbyRelaySample.Lobby.LobbyAPIInterface.DeleteLobbyAsync(room.Id, null); // The onComplete callback isn't called in some error cases, e.g. a 403 when we don't have permissions, so don't block on it.
yield return new WaitForSeconds(1); // We need to wait a little to avoid 429's, but we might not run an onComplete depending on how the delete call fails.
}
}
}