Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions Runtime/Client/EndPointClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,50 @@ public EndPointClass(string endPoint, LootLockerHTTPMethod httpMethod, LootLocke

public string WithPathParameter(object arg0)
{
return string.Format(endPoint, WebUtility.UrlEncode(arg0.ToString()));
try {
return string.Format(endPoint, WebUtility.UrlEncode(arg0?.ToString() ?? "null"));
}
catch (FormatException e)
{
LootLockerLogger.Log($"Error formatting endpoint \"{endPoint}\" with path parameter \"{WebUtility.UrlEncode(arg0?.ToString() ?? "null")}\": {e}", LootLockerLogger.LogLevel.Error);
return endPoint;
}
}

public string WithPathParameters(object arg0, object arg1)
{
return string.Format(endPoint, WebUtility.UrlEncode(arg0.ToString()), WebUtility.UrlEncode(arg1.ToString()));
try {
return string.Format(endPoint, WebUtility.UrlEncode(arg0?.ToString() ?? "null"), WebUtility.UrlEncode(arg1?.ToString() ?? "null"));
}
catch (FormatException e)
{
LootLockerLogger.Log($"Error formatting endpoint \"{endPoint}\" with path parameters \"{WebUtility.UrlEncode(arg0?.ToString() ?? "null")}\", \"{WebUtility.UrlEncode(arg1?.ToString() ?? "null")}\": {e}", LootLockerLogger.LogLevel.Error);
return endPoint;
}
}

public string WithPathParameters(object arg0, object arg1, object arg2)
{
return string.Format(endPoint, WebUtility.UrlEncode(arg0.ToString()), WebUtility.UrlEncode(arg1.ToString()), WebUtility.UrlEncode(arg2.ToString()));
try {
return string.Format(endPoint, WebUtility.UrlEncode(arg0?.ToString() ?? "null"), WebUtility.UrlEncode(arg1?.ToString() ?? "null"), WebUtility.UrlEncode(arg2?.ToString() ?? "null"));
}
catch (FormatException e)
{
LootLockerLogger.Log($"Error formatting endpoint \"{endPoint}\" with path parameters \"{WebUtility.UrlEncode(arg0?.ToString() ?? "null")}\", \"{WebUtility.UrlEncode(arg1?.ToString() ?? "null")}\", \"{WebUtility.UrlEncode(arg2?.ToString() ?? "null")}\": {e}", LootLockerLogger.LogLevel.Error);
return endPoint;
}
}

public string WithPathParameters(object arg0, object arg1, object arg2, object arg3)
{
return string.Format(endPoint, WebUtility.UrlEncode(arg0.ToString()), WebUtility.UrlEncode(arg1.ToString()), WebUtility.UrlEncode(arg2.ToString()), WebUtility.UrlEncode(arg3.ToString()));
try {
return string.Format(endPoint, WebUtility.UrlEncode(arg0?.ToString() ?? "null"), WebUtility.UrlEncode(arg1?.ToString() ?? "null"), WebUtility.UrlEncode(arg2?.ToString() ?? "null"), WebUtility.UrlEncode(arg3?.ToString() ?? "null"));
}
catch (FormatException e)
{
LootLockerLogger.Log($"Error formatting endpoint \"{endPoint}\" with path parameters \"{WebUtility.UrlEncode(arg0?.ToString() ?? "null")}\", \"{WebUtility.UrlEncode(arg1?.ToString() ?? "null")}\", \"{WebUtility.UrlEncode(arg2?.ToString() ?? "null")}\", \"{WebUtility.UrlEncode(arg3?.ToString() ?? "null")}\": {e}", LootLockerLogger.LogLevel.Error);
return endPoint;
}
}
}
}
2 changes: 1 addition & 1 deletion Runtime/Client/LootLockerEndPoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public class LootLockerEndPoints
[Header("Catalogs")]
public static EndPointClass listCatalogs = new EndPointClass("catalogs", LootLockerHTTPMethod.GET);
public static EndPointClass deprecatedListCatalogItemsByKey = new EndPointClass("catalog/key/{0}/prices", LootLockerHTTPMethod.GET);
public static EndPointClass listCatalogItemsByKey = new EndPointClass("catalogs/inspired-ibex/v1/catalog/key/{key}/list", LootLockerHTTPMethod.GET);
public static EndPointClass listCatalogItemsByKey = new EndPointClass("catalogs/inspired-ibex/v1/catalog/key/{0}/list", LootLockerHTTPMethod.GET);

// Misc
[Header("Misc")]
Expand Down
9 changes: 6 additions & 3 deletions Runtime/Client/LootLockerHTTPClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@ private void CallListenersAndMarkDone(LootLockerHTTPExecutionQueueItem execution
executionItem.Done = true;
response.requestContext = new LootLockerRequestContext(executionItem.RequestData.ForPlayerWithUlid, executionItem.RequestData.RequestStartTime);
executionItem.Response = response;
if (!CompletedRequestIDs.Contains(executionItem.RequestData.RequestId))
{
CompletedRequestIDs.Add(executionItem.RequestData.RequestId);
}
executionItem.RequestData.CallListenersWithResult(response);
CompletedRequestIDs.Add(executionItem.RequestData.RequestId);
}

private IEnumerator RefreshSession(string refreshForPlayerUlid, string forExecutionItemId, Action<LootLockerSessionResponse, string, string> onSessionRefreshedCallback)
Expand Down Expand Up @@ -647,8 +650,6 @@ private IEnumerator RefreshSession(string refreshForPlayerUlid, string forExecut
}, refreshForPlayerUlid);
}
break;
case LL_AuthPlatforms.PlayStationNetwork:
case LL_AuthPlatforms.XboxOne:
case LL_AuthPlatforms.AmazonLuna:
{
LootLockerSDKManager.StartAmazonLunaSession(playerData.Identifier, (response) =>
Expand All @@ -658,6 +659,8 @@ private IEnumerator RefreshSession(string refreshForPlayerUlid, string forExecut
}, playerData.SessionOptionals);
}
break;
case LL_AuthPlatforms.PlayStationNetwork:
case LL_AuthPlatforms.XboxOne:
case LL_AuthPlatforms.NintendoSwitch:
case LL_AuthPlatforms.Steam:
{
Expand Down
9 changes: 8 additions & 1 deletion Runtime/Client/LootLockerHttpRequestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ public void CallListenersWithResult(LootLockerResponse response)
{
foreach(var listener in Listeners)
{
listener?.Invoke(response);
try
{
listener?.Invoke(response);
}
catch (Exception e)
{
LootLockerLogger.Log($"Exception thrown in HTTP request listener for request id {RequestId}. Exception was: {e}.", LootLockerLogger.LogLevel.Error);
}
}
HaveListenersBeenInvoked = true;
}
Expand Down
9 changes: 8 additions & 1 deletion Runtime/Client/LootLockerStateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public static LootLockerPlayerData GetStateForPlayerOrDefaultStateOrEmpty(string
}
string playerULIDToGetDataFor = string.IsNullOrEmpty(playerULID) ? ActiveMetaData.DefaultPlayer : playerULID;

// Make this player the default for requests if there is no default yet or if the current default is not currently active
bool shouldBeMadeDefault = ActivePlayerData.Count == 0 && !playerULIDToGetDataFor.Equals(ActiveMetaData.DefaultPlayer, StringComparison.OrdinalIgnoreCase);

if (ActivePlayerData.TryGetValue(playerULIDToGetDataFor, out var data))
{
return data;
Expand All @@ -204,6 +207,10 @@ public static LootLockerPlayerData GetStateForPlayerOrDefaultStateOrEmpty(string
{
if (ActivePlayerData.TryGetValue(playerULIDToGetDataFor, out var data2))
{
if (shouldBeMadeDefault)
{
SetDefaultPlayerULID(data2.ULID);
}
return data2;
}
}
Expand Down Expand Up @@ -264,7 +271,7 @@ public static bool SetPlayerData(LootLockerPlayerData updatedPlayerData)
{
ActiveMetaData.WhiteLabelEmailToPlayerUlidMap[updatedPlayerData.WhiteLabelEmail] = updatedPlayerData.ULID;
}
if (string.IsNullOrEmpty(ActiveMetaData.DefaultPlayer))
if (string.IsNullOrEmpty(ActiveMetaData.DefaultPlayer) || !ActivePlayerData.ContainsKey(ActiveMetaData.DefaultPlayer))
{
SetDefaultPlayerULID(updatedPlayerData.ULID);
}
Expand Down
52 changes: 41 additions & 11 deletions Runtime/Game/LootLockerSDKManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3242,6 +3242,40 @@ public static void LookupPlayerNamesByXboxIds(string[] xboxIds, Action<PlayerNam
LootLockerAPIManager.LookupPlayerNames(forPlayerWithUlid, "xbox_id", xboxIds, onComplete);
}

/// <summary>
/// Get player names and important ids of a set of players from their last active platform by Epic Games ID's
/// </summary>
/// <param name="epicGamesIds">A list of multiple player Epic Games ID's</param>
/// <param name="onComplete">onComplete Action for handling the response of type PlayerNameLookupResponse</param>
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
public static void LookupPlayerNamesByEpicGamesIds(string[] epicGamesIds, Action<PlayerNameLookupResponse> onComplete, string forPlayerWithUlid = null)
{
if (!CheckInitialized(false, forPlayerWithUlid))
{
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>(forPlayerWithUlid));
return;
}

LootLockerAPIManager.LookupPlayerNames(forPlayerWithUlid, "epic_games_id", epicGamesIds, onComplete);
}

/// <summary>
/// Get player names and important ids of a set of players from their last active platform by Google Play Games ID's
/// </summary>
/// <param name="googlePlayGamesIds">A list of multiple player Google Play Games ID's</param>
/// <param name="onComplete">onComplete Action for handling the response of type PlayerNameLookupResponse</param>
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
public static void LookupPlayerNamesByGooglePlayGamesIds(string[] googlePlayGamesIds, Action<PlayerNameLookupResponse> onComplete, string forPlayerWithUlid = null)
{
if (!CheckInitialized(false, forPlayerWithUlid))
{
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<PlayerNameLookupResponse>(forPlayerWithUlid));
return;
}

LootLockerAPIManager.LookupPlayerNames(forPlayerWithUlid, "google_play_games_id", googlePlayGamesIds, onComplete);
}

/// <summary>
/// Mark the logged in player for deletion. After 30 days the player will be deleted from the system.
/// </summary>
Expand Down Expand Up @@ -4025,17 +4059,18 @@ public static void GetHeroInventory(int heroID, Action<LootLockerInventoryRespon
/// <summary>
/// List the loadout of the specified hero that the current player owns
/// </summary>
/// <param name="heroID">HeroID Id of the hero</param>
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
public static void GetHeroLoadout(Action<LootLockerHeroLoadoutResponse> onComplete, string forPlayerWithUlid = null)
public static void GetHeroLoadout(int HeroID, Action<LootLockerHeroLoadoutResponse> onComplete, string forPlayerWithUlid = null)
{
if (!CheckInitialized(false, forPlayerWithUlid))
{
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>(forPlayerWithUlid));
return;
}

LootLockerAPIManager.GetHeroLoadout(forPlayerWithUlid, onComplete);
LootLockerAPIManager.GetHeroLoadout(forPlayerWithUlid, HeroID, onComplete);
}

/// <summary>
Expand Down Expand Up @@ -4076,7 +4111,7 @@ public static void AddAssetToHeroLoadout(int heroID, int assetInstanceID, Action
data.hero_id = heroID;


LootLockerAPIManager.AddAssetToHeroLoadout(forPlayerWithUlid, data, onComplete);
LootLockerAPIManager.AddAssetToHeroLoadout(forPlayerWithUlid, heroID, data, onComplete);
}

/// <summary>
Expand All @@ -4102,7 +4137,7 @@ public static void AddAssetVariationToHeroLoadout(int heroID, int assetID, int a
data.asset_id = assetID;
data.asset_variation_id = assetInstanceID;

LootLockerAPIManager.AddAssetVariationToHeroLoadout(forPlayerWithUlid, data, onComplete);
LootLockerAPIManager.AddAssetVariationToHeroLoadout(forPlayerWithUlid, heroID, data, onComplete);
}

/// <summary>
Expand All @@ -4113,20 +4148,15 @@ public static void AddAssetVariationToHeroLoadout(int heroID, int assetID, int a
/// <param name="heroID">Id of the hero</param>
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
public static void RemoveAssetFromHeroLoadout(string assetID, string heroID, Action<LootLockerHeroLoadoutResponse> onComplete, string forPlayerWithUlid = null)
public static void RemoveAssetFromHeroLoadout(int assetID, int heroID, Action<LootLockerHeroLoadoutResponse> onComplete, string forPlayerWithUlid = null)
{
if (!CheckInitialized(false, forPlayerWithUlid))
{
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>(forPlayerWithUlid));
return;
}

LootLockerGetRequest lootLockerGetRequest = new LootLockerGetRequest();

lootLockerGetRequest.getRequests.Add(assetID);
lootLockerGetRequest.getRequests.Add(heroID);

LootLockerAPIManager.RemoveAssetFromHeroLoadout(forPlayerWithUlid, lootLockerGetRequest, onComplete);
LootLockerAPIManager.RemoveAssetFromHeroLoadout(forPlayerWithUlid, heroID, assetID, onComplete);
}

#endregion
Expand Down
Loading
Loading