浏览代码

Fixed instant crash bug from recursive Task adding.

Removing Queueing Tasks for now, we’ll figure out a better way to do it in the future.
/main/staging/2021_Upgrade
当前提交
c7c865a7
共有 2 个文件被更改,包括 7 次插入26 次删除
  1. 31
      Assets/Scripts/GameLobby/Lobby/LobbyAsyncRequests.cs
  2. 2
      Assets/Scripts/GameLobby/Tests/PlayMode/LobbyRoundtripTests.cs

31
Assets/Scripts/GameLobby/Lobby/LobbyAsyncRequests.cs


/// <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>
public async Task<QueryResponse> RetrieveLobbyListAsync(LobbyColor limitToColor = LobbyColor.None)
{
if (!await m_rateLimitQuery.WaitInQueueUntilTaskIsFirst(
RetrieveLobbyListAsync(limitToColor)))
return null;
await m_rateLimitQuery.WaitUntilCooldown();
Debug.Log("Retrieving Lobby List");
var filters = LobbyColorToFilters(limitToColor);

public async Task UpdatePlayerDataAsync(Dictionary<string, string> data)
{
if (!await m_rateLimitQuery.WaitInQueueUntilTaskIsFirst(
UpdatePlayerDataAsync(data)))
return;
await m_rateLimitQuery.WaitUntilCooldown();
string playerId = Locator.Get.Identity.GetSubIdentity(Auth.IIdentityType.Auth).GetContent("id");
Dictionary<string, PlayerDataObject> dataCurr = new Dictionary<string, PlayerDataObject>();
foreach (var dataNew in data)

public async Task UpdatePlayerRelayInfoAsync(string allocationId, string connectionInfo)
{
if (!await m_rateLimitQuery.WaitInQueueUntilTaskIsFirst(
UpdatePlayerRelayInfoAsync(allocationId, connectionInfo)))
return;
await m_rateLimitQuery.WaitUntilCooldown();
await AwaitRemoteLobby();
string playerId = Locator.Get.Identity.GetSubIdentity(Auth.IIdentityType.Auth).GetContent("id");

/// <param name="data">Key-value pairs, which will overwrite any existing data for these keys. Presumed to be available to all lobby members but not publicly.</param>
public async Task UpdateLobbyDataAsync(Dictionary<string, string> data)
{
if (await m_rateLimitQuery.WaitInQueueUntilTaskIsFirst(UpdateLobbyDataAsync(data)))
return;
await m_rateLimitQuery.WaitUntilCooldown();
Dictionary<string, DataObject> dataCurr = m_RemoteLobby.Data ?? new Dictionary<string, DataObject>();

}
public async Task<bool> WaitInQueueUntilTaskIsFirst(Task newTask)
public async Task WaitUntilCooldown() //TODO YAGNI Handle Multiple commands? Return bool if already waiting?
//Task is already in the queue
if (m_TaskQueue.Contains(newTask))
return false;
Debug.Log($"Enqueing Task: {newTask.Id} - {newTask.Status}");
return true;
Debug.LogWarning("Hit the rate limit. Queueing...");
return;
m_TaskQueue.Enqueue(newTask);
if (m_DequeuedTask == newTask)
break;
//Got to the part of the queue that was the Task'
return true;
}
bool CanCall()

2
Assets/Scripts/GameLobby/Tests/PlayMode/LobbyRoundtripTests.cs


float timeout = 5;
Debug.Log("Getting Lobby List 1");
QueryResponse queryResponse = null;
yield return AsyncTestHelper.Await(async () => queryResponse = await LobbyAsyncRequests.Instance.RetrieveLobbyListAsync());
yield return AsyncTestHelper.Await(async () => queryResponse = await LobbyAsyncRequests.Instance.RetrieveLobbyListAsync());
Debug.Log("Got Lobby List 1");

正在加载...
取消
保存