@@ -105,7 +105,7 @@ public class LootLockerLeaseRemoteSessionResponse : LootLockerResponse
105
105
public class LootLockerRemoteSessionStatusPollingResponse : LootLockerResponse
106
106
{
107
107
/// <summary>
108
- /// The current status of this lease process. If this is not of the status Authorized, the rest of the fields in this object will be empty.
108
+ /// The current status of this lease process.
109
109
/// </summary>
110
110
public LootLockerRemoteSessionLeaseStatus lease_status { get ; set ; }
111
111
}
@@ -166,8 +166,6 @@ static void OnEnterPlaymodeInEditor(EnterPlayModeOptions options)
166
166
}
167
167
#endif
168
168
169
- private static readonly double _leasingProcessTimeoutLimitInMinutes = 5.0d ;
170
- private static readonly float _leasingProcessPollingIntervalSeconds = 1.0f ;
171
169
private static readonly int _leasingProcessPollingRetryLimit = 5 ;
172
170
173
171
private class LootLockerRemoteSessionProcess
@@ -176,6 +174,7 @@ private class LootLockerRemoteSessionProcess
176
174
public string LeaseNonce ;
177
175
public LootLockerRemoteSessionLeaseStatus LastUpdatedStatus ;
178
176
public DateTime LeasingProcessTimeoutTime ;
177
+ public float PollingIntervalSeconds = 1.0f ;
179
178
public DateTime LastUpdatedAt ;
180
179
public int Retries = 0 ;
181
180
public bool ShouldCancel ;
@@ -202,7 +201,11 @@ private static void RemoveRemoteSessionProcess(Guid processGuid)
202
201
203
202
protected IEnumerator ContinualPollingAction ( Guid processGuid )
204
203
{
205
- yield return new WaitForSeconds ( _leasingProcessPollingIntervalSeconds ) ;
204
+ if ( ! _remoteSessionsProcesses . TryGetValue ( processGuid , out var preProcess ) )
205
+ {
206
+ yield break ;
207
+ }
208
+ yield return new WaitForSeconds ( preProcess . PollingIntervalSeconds ) ;
206
209
while ( _remoteSessionsProcesses . TryGetValue ( processGuid , out var process ) )
207
210
{
208
211
// Check if we should continue the polling
@@ -221,6 +224,7 @@ protected IEnumerator ContinualPollingAction(Guid processGuid)
221
224
{
222
225
LootLockerStartRemoteSessionResponse canceledResponse = new LootLockerStartRemoteSessionResponse
223
226
{
227
+ success = false ,
224
228
lease_status = LootLockerRemoteSessionLeaseStatus . Cancelled
225
229
} ;
226
230
process . ProcessCompletedCallbackAction ? . Invoke ( canceledResponse ) ;
@@ -246,7 +250,7 @@ protected IEnumerator ContinualPollingAction(Guid processGuid)
246
250
{
247
251
// Recoverable error
248
252
processAfterStatusCheck . Retries ++ ;
249
- yield return new WaitForSeconds ( _leasingProcessPollingIntervalSeconds ) ;
253
+ yield return new WaitForSeconds ( processAfterStatusCheck . PollingIntervalSeconds ) ;
250
254
continue ;
251
255
}
252
256
@@ -256,6 +260,7 @@ protected IEnumerator ContinualPollingAction(Guid processGuid)
256
260
yield break ;
257
261
}
258
262
263
+ // Authorized = We're done
259
264
if ( startSessionResponse . lease_status == LootLockerRemoteSessionLeaseStatus . Authorized )
260
265
{
261
266
processAfterStatusCheck . ProcessCompletedCallbackAction ? . Invoke ( startSessionResponse ) ;
@@ -269,16 +274,19 @@ protected IEnumerator ContinualPollingAction(Guid processGuid)
269
274
startSessionResponse ) ;
270
275
processAfterStatusCheck . UpdateCallbackAction ? . Invoke ( pollingResponse ) ;
271
276
processAfterStatusCheck . LastUpdatedAt = DateTime . UtcNow ;
277
+ processAfterStatusCheck . LastUpdatedStatus = pollingResponse . lease_status ;
272
278
273
279
// Sleep for a bit before checking again
274
- yield return new WaitForSeconds ( _leasingProcessPollingIntervalSeconds ) ;
280
+ yield return new WaitForSeconds ( processAfterStatusCheck . PollingIntervalSeconds ) ;
275
281
}
276
282
}
277
283
278
284
public Guid StartRemoteSessionWithContinualPolling (
279
285
Action < LootLockerLeaseRemoteSessionResponse > remoteSessionLeaseInformation ,
280
286
Action < LootLockerRemoteSessionStatusPollingResponse > remoteSessionLeaseStatusUpdateCallback ,
281
- Action < LootLockerStartRemoteSessionResponse > remoteSessionCompleted )
287
+ Action < LootLockerStartRemoteSessionResponse > remoteSessionCompleted ,
288
+ float pollingIntervalSeconds = 1.0f ,
289
+ float timeOutAfterMinutes = 5.0f )
282
290
{
283
291
if ( _remoteSessionsProcesses . Count > 0 )
284
292
{
@@ -292,7 +300,8 @@ public Guid StartRemoteSessionWithContinualPolling(
292
300
LootLockerRemoteSessionProcess lootLockerRemoteSessionProcess = new LootLockerRemoteSessionProcess ( )
293
301
{
294
302
LastUpdatedAt = DateTime . UtcNow ,
295
- LeasingProcessTimeoutTime = DateTime . UtcNow . AddMinutes ( _leasingProcessTimeoutLimitInMinutes ) ,
303
+ LeasingProcessTimeoutTime = DateTime . UtcNow . AddMinutes ( timeOutAfterMinutes ) ,
304
+ PollingIntervalSeconds = pollingIntervalSeconds ,
296
305
UpdateCallbackAction = remoteSessionLeaseStatusUpdateCallback ,
297
306
ProcessCompletedCallbackAction = remoteSessionCompleted
298
307
} ;
@@ -310,6 +319,7 @@ public Guid StartRemoteSessionWithContinualPolling(
310
319
remoteSessionLeaseInformation ? . Invoke ( leaseRemoteSessionResponse ) ;
311
320
return ;
312
321
}
322
+ remoteSessionLeaseInformation ? . Invoke ( leaseRemoteSessionResponse ) ;
313
323
314
324
process . LeaseCode = leaseRemoteSessionResponse . code ;
315
325
process . LeaseNonce = leaseRemoteSessionResponse . nonce ;
@@ -365,7 +375,7 @@ private void StartRemoteSession(string leaseCode, string nonce, Action<LootLocke
365
375
CurrentPlatform . Set ( Platforms . Remote ) ;
366
376
LootLockerConfig . current . token = response . session_token ;
367
377
LootLockerConfig . current . refreshToken = response . refresh_token ;
368
- LootLockerConfig . current . deviceID = response . player_identifier ;
378
+ LootLockerConfig . current . deviceID = response . player_ulid ;
369
379
}
370
380
371
381
onComplete ? . Invoke ( response ) ;
0 commit comments