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;
}
}
}
}
5 changes: 4 additions & 1 deletion 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
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
2 changes: 1 addition & 1 deletion Runtime/Game/Utilities/LootLockerHttpUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public string Build()

foreach (KeyValuePair<string, string> pair in _queryParams)
{
if (string.IsNullOrEmpty(pair.Value))
if (string.IsNullOrEmpty(pair.Key) || string.IsNullOrEmpty(pair.Value))
continue;

if (query.Length > 1)
Expand Down
Loading