Skip to content

Commit d458aaf

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Add support for leasing and starting remote sessions
This will introduce a slightly new design for an SDK future in that we only provide 1 method that will automatically handle the complete flow.
1 parent e1b614f commit d458aaf

File tree

6 files changed

+455
-2
lines changed

6 files changed

+455
-2
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public class LootLockerEndPoints
2323
public static EndPointClass appleGameCenterSessionRequest = new EndPointClass("session/apple/game-center", LootLockerHTTPMethod.POST);
2424
public static EndPointClass googleSessionRequest = new EndPointClass("session/google", LootLockerHTTPMethod.POST);
2525

26+
// Remote Sessions
27+
[Header("Remote Sessions")]
28+
public static EndPointClass leaseRemoteSession = new EndPointClass("session/remote/lease", LootLockerHTTPMethod.POST);
29+
public static EndPointClass startRemoteSession = new EndPointClass("session/remote", LootLockerHTTPMethod.POST);
30+
2631
// White Label Login
2732
[Header("White Label Login")]
2833
public static EndPointClass whiteLabelSignUp = new EndPointClass("white-label-login/sign-up", LootLockerHTTPMethod.POST);

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
using UnityEngine;
55
using System.Text;
66
using LootLocker.LootLockerEnums;
7-
using static LootLocker.LootLockerConfig;
87
using System.Linq;
98
using System.Security.Cryptography;
10-
using static LootLocker.Requests.CurrentPlatform;
119
#if UNITY_EDITOR
1210
using UnityEditor;
1311
#endif
@@ -808,6 +806,37 @@ public static void ClearLocalSession()
808806
}
809807
#endregion
810808

809+
#region Remote Sessions
810+
/// <summary>
811+
/// Start a remote session
812+
/// 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.
814+
/// When the process has come to an end (whether successfully or not), the onComplete action will be invoked with the updated information.
815+
/// </summary>
816+
/// <param name="remoteSessionLeaseInformation">Will be invoked once to provide the lease information that the secondary device can use to authenticate</param>
817+
/// <param name="remoteSessionLeaseStatusUpdate">Will be invoked intermittently to update the status lease process</param>
818+
/// <param name="onComplete">Invoked when the remote session process has run to completion containing either a valid session or information on why the process failed</param>
819+
public static Guid StartRemoteSession(Action<LootLockerLeaseRemoteSessionResponse> remoteSessionLeaseInformation, Action<LootLockerRemoteSessionStatusPollingResponse> remoteSessionLeaseStatusUpdate, Action<LootLockerStartRemoteSessionResponse> onComplete)
820+
{
821+
if (!CheckInitialized(true))
822+
{
823+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerStartRemoteSessionResponse>());
824+
return Guid.Empty;
825+
}
826+
827+
return LootLockerAPIManager.RemoteSessionPoller.GetInstance().StartRemoteSessionWithContinualPolling(remoteSessionLeaseInformation, remoteSessionLeaseStatusUpdate, onComplete);
828+
}
829+
830+
/// <summary>
831+
/// Cancel an ongoing remote session process
832+
/// </summary>
833+
/// <param name="guid">The guid of the remote session process that you want to cancel</param>
834+
public static void CancelRemoteSessionProcess(Guid guid)
835+
{
836+
LootLockerAPIManager.RemoteSessionPoller.GetInstance().CancelRemoteSessionProcess(guid);
837+
}
838+
#endregion
839+
811840
#region White Label
812841

813842
/// <summary>

Runtime/Game/Platforms/PlatformManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum Platforms
2222
,Google
2323
,Epic
2424
,Meta
25+
,Remote
2526
}
2627

2728
public class CurrentPlatform
@@ -55,6 +56,7 @@ static CurrentPlatform()
5556
,"google_sign_in" // Google
5657
,"epic_games" // Epic Online Services / Epic Games
5758
,"meta" // Meta
59+
,"remote" // Remote (leased) session
5860
};
5961

6062
private static readonly string[] PlatformFriendlyStrings = new[]
@@ -73,6 +75,7 @@ static CurrentPlatform()
7375
,"Google" // Google
7476
,"Epic Online Services" // Epic Online Services / Epic Games
7577
,"Meta" // Meta
78+
,"Remote" // Remote (leased) session
7679
};
7780

7881
public struct PlatformRepresentation

Runtime/Game/Requests/LootLockerSessionRequest.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,57 @@ public LootLockerWhiteLabelSessionRequest()
4646
[Serializable]
4747
public class LootLockerSessionResponse : LootLockerResponse
4848
{
49+
/// <summary>
50+
/// The session token that can now be used to use further LootLocker functionality. We store and use this for you.
51+
/// </summary>
4952
public string session_token { get; set; }
53+
/// <summary>
54+
/// The player id
55+
/// </summary>
5056
public int player_id { get; set; }
57+
/// <summary>
58+
/// Whether this player has been seen before (true) or is new (false)
59+
/// </summary>
5160
public bool seen_before { get; set; }
61+
/// <summary>
62+
/// The public UID for this player
63+
/// </summary>
5264
public string public_uid { get; set; }
65+
/// <summary>
66+
/// The player ULID for this player
67+
/// </summary>
5368
public string player_ulid { get; set; }
69+
/// <summary>
70+
/// The creation time of this player
71+
/// </summary>
5472
public DateTime player_created_at { get; set; }
73+
/// <summary>
74+
/// Whether this player has new information to check in grants
75+
/// </summary>
5576
public bool check_grant_notifications { get; set; }
77+
/// <summary>
78+
/// Whether this player has new information to check in deactivations
79+
/// </summary>
5680
public bool check_deactivation_notifications { get; set; }
81+
/// <summary>
82+
/// Whether this player has new information to check in dlcs
83+
/// </summary>
5784
public int[] check_dlcs { get; set; }
85+
/// <summary>
86+
/// The current xp of this player
87+
/// </summary>
5888
public int xp { get; set; }
89+
/// <summary>
90+
/// The current level of this player
91+
/// </summary>
5992
public int level { get; set; }
93+
/// <summary>
94+
/// The level_thresholds that the level and xp data relates to
95+
/// </summary>
6096
public LootLockerLevel_Thresholds level_thresholds { get; set; }
97+
/// <summary>
98+
/// The current balance in this account
99+
/// </summary>
61100
public int account_balance { get; set; }
62101
}
63102

0 commit comments

Comments
 (0)