Skip to content

Commit 9132b7b

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Auto retry remote session polling on recoverable errors
1 parent d458aaf commit 9132b7b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ public static void ClearLocalSession()
810810
/// <summary>
811811
/// Start a remote session
812812
/// If you want to let your local user sign in using another device then you use this method. First you will get the lease information needed to allow a secondary device to authenticate.
813-
/// While the process is ongoing, the remoteSessionLeaseStatusUpdate action (if one is provided) will be invoked intermittently to update you on the status of the process.
813+
/// While the process is ongoing, the remoteSessionLeaseStatusUpdate action (if one is provided) will be invoked intermittently (about once a second) to update you on the status of the process.
814814
/// When the process has come to an end (whether successfully or not), the onComplete action will be invoked with the updated information.
815815
/// </summary>
816816
/// <param name="remoteSessionLeaseInformation">Will be invoked once to provide the lease information that the secondary device can use to authenticate</param>

Runtime/Game/Requests/RemoteSessionRequest.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ static void OnEnterPlaymodeInEditor(EnterPlayModeOptions options)
167167
#endif
168168

169169
private static readonly double _leasingProcessTimeoutLimitInMinutes = 5.0d;
170-
private static readonly int _leasingProcessPollingIntervalSeconds = 1;
170+
private static readonly float _leasingProcessPollingIntervalSeconds = 1.0f;
171+
private static readonly int _leasingProcessPollingRetryLimit = 5;
171172

172173
private class LootLockerRemoteSessionProcess
173174
{
@@ -176,6 +177,7 @@ private class LootLockerRemoteSessionProcess
176177
public LootLockerRemoteSessionLeaseStatus LastUpdatedStatus;
177178
public DateTime LeasingProcessTimeoutTime;
178179
public DateTime LastUpdatedAt;
180+
public int Retries = 0;
179181
public bool ShouldCancel;
180182
public Action<LootLockerRemoteSessionStatusPollingResponse> UpdateCallbackAction;
181183
public Action<LootLockerStartRemoteSessionResponse> ProcessCompletedCallbackAction;
@@ -238,8 +240,16 @@ protected IEnumerator ContinualPollingAction(Guid processGuid)
238240
yield break;
239241
}
240242

241-
if (!startSessionResponse.success) //TODO: auto recover on 500s
243+
if (!startSessionResponse.success)
242244
{
245+
if (startSessionResponse.statusCode >= 500 && startSessionResponse.statusCode <= 599 && processAfterStatusCheck.Retries <= _leasingProcessPollingRetryLimit)
246+
{
247+
// Recoverable error
248+
processAfterStatusCheck.Retries++;
249+
yield return new WaitForSeconds(_leasingProcessPollingIntervalSeconds);
250+
continue;
251+
}
252+
243253
startSessionResponse.lease_status = LootLockerRemoteSessionLeaseStatus.Failed;
244254
processAfterStatusCheck.ProcessCompletedCallbackAction?.Invoke(startSessionResponse);
245255
RemoveRemoteSessionProcess(processGuid);

0 commit comments

Comments
 (0)