Skip to content

Commit fa9aac4

Browse files
committed
Support Enter Playmode Settings in RateLimiter
1 parent 34fc7c2 commit fa9aac4

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Runtime/Client/LootLockerServerRequest.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using LootLocker.LootLockerEnums;
66
using LootLocker.Requests;
77
using Newtonsoft.Json.Serialization;
8+
using UnityEditor;
89

910

1011
// using LootLocker.Admin;
@@ -279,10 +280,31 @@ protected int GetMaxRequestsInSingleBucket()
279280
return maxRequests;
280281
}
281282

282-
private static readonly RateLimiter _rateLimiter = new RateLimiter();
283-
public static RateLimiter Get() { return _rateLimiter; }
284-
}
283+
private static RateLimiter _rateLimiter = null;
284+
285+
public static RateLimiter Get()
286+
{
287+
if (_rateLimiter == null)
288+
{
289+
Reset();
290+
}
291+
return _rateLimiter;
292+
}
293+
294+
public static void Reset()
295+
{
296+
_rateLimiter = new RateLimiter();
297+
}
285298

299+
#if UNITY_EDITOR
300+
[InitializeOnEnterPlayMode]
301+
static void OnEnterPlaymodeInEditor(EnterPlayModeOptions options)
302+
{
303+
LootLockerLogger.GetForLogLevel()("Reset RateLimiter due to entering play mode");
304+
Reset();
305+
}
306+
#endif
307+
}
286308
#endregion
287309

288310
/// <summary>

0 commit comments

Comments
 (0)