您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

33 行
1.3 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Temporary script to allow a user to delete all the rooms they've previously made, so we don't have orphaned empty rooms.
/// </summary>
public class TempDeleteAllRooms : MonoBehaviour
{
private Queue<Unity.Services.Rooms.Models.Room> m_pendingRooms;
public void OnButton()
{
LobbyRelaySample.Lobby.RoomsInterface.QueryAllRoomsAsync((qr) => { DoDeletes(qr); });
}
private void DoDeletes(Unity.Services.Rooms.Response<Unity.Services.Rooms.Models.QueryResponse> response)
{
if (response != null && response.Status >= 200 && response.Status < 300)
{
StartCoroutine(DeleteCoroutine(response.Result.Results));
}
}
private IEnumerator DeleteCoroutine(List<Unity.Services.Rooms.Models.Room> rooms)
{
foreach (var room in rooms)
{
LobbyRelaySample.Lobby.RoomsInterface.DeleteRoomAsync(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.
}
}
}