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
30 changes: 13 additions & 17 deletions Assets/Talo Game Services/Talo/Runtime/APIs/PlayersAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum DebouncedOperation
Update
}

public event Action<Player> OnIdentified;
public event Action<PlayerAlias> OnIdentified;
public event Action OnIdentificationStarted;
public event Action OnIdentificationFailed;
public event Action OnIdentityCleared;
Expand All @@ -43,10 +43,10 @@ private async void OnConnectionRestored()

public void InvokeIdentifiedEvent()
{
OnIdentified?.Invoke(Talo.CurrentPlayer);
OnIdentified?.Invoke(Talo.CurrentAlias);
}

private async Task<Player> HandleIdentifySuccess(PlayerAlias alias, string socketToken = "")
private async Task<PlayerAlias> HandleIdentifySuccess(PlayerAlias alias, string socketToken = "")
{
if (!Talo.IsOffline() && Talo.Socket.IsIdentified())
{
Expand All @@ -61,10 +61,10 @@ private async Task<Player> HandleIdentifySuccess(PlayerAlias alias, string socke

InvokeIdentifiedEvent();

return alias.player;
return alias;
}

public async Task<Player> Identify(string service, string identifier)
public async Task<PlayerAlias> Identify(string service, string identifier)
{
OnIdentificationStarted?.Invoke();

Expand Down Expand Up @@ -92,27 +92,24 @@ public async Task<Player> Identify(string service, string identifier)
}
}

public async Task<Player> IdentifySteam(string ticket, string identityClient = "")
public async Task<PlayerAlias> IdentifySteam(string ticket, string identityClient = "")
{
if (string.IsNullOrEmpty(identityClient))
{
await Identify("steam", ticket);
return await Identify("steam", ticket);
}
else
{
await Identify("steam", $"{identityClient}:{ticket}");
return await Identify("steam", $"{identityClient}:{ticket}");
}

return Talo.CurrentPlayer;
}

public async Task<Player> IdentifyGooglePlayGames(string authCode)
public async Task<PlayerAlias> IdentifyGooglePlayGames(string authCode)
{
await Identify("google_play_games", authCode);
return Talo.CurrentPlayer;
return await Identify("google_play_games", authCode);
}

public async Task<Player> IdentifyGameCenter(
public async Task<PlayerAlias> IdentifyGameCenter(
string publicKeyUrl,
byte[] signature,
byte[] salt,
Expand All @@ -132,8 +129,7 @@ string playerId

var identifier = Uri.EscapeDataString(JsonUtility.ToJson(payload));

await Identify("game_center", identifier);
return Talo.CurrentPlayer;
return await Identify("game_center", identifier);
}

protected override async Task ExecuteDebouncedOperation(DebouncedOperation operation)
Expand Down Expand Up @@ -203,7 +199,7 @@ public async Task<Player> Find(string playerId)
return res.player;
}

private async Task<Player> IdentifyOffline(string service, string identifier)
private async Task<PlayerAlias> IdentifyOffline(string service, string identifier)
{
PlayerAlias offlineAlias;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ private void OnDisable()
Talo.Players.OnIdentified -= OnIdentified;
}

private void OnIdentified(Player player)
private void OnIdentified(PlayerAlias alias)
{
root.Q<Label>("title").text = $"Hi, {Talo.CurrentAlias.identifier}";
root.Q<Label>("title").text = $"Hi, {alias.identifier}";
}

private async void OnLogoutClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private void OnDisable()
Talo.Players.OnIdentified -= OnIdentified;
}

private void OnIdentified(Player player)
private void OnIdentified(PlayerAlias alias)
{
GoToGame();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ private async Task Identify()
}
}

private void OnIdentified(Player player)
private void OnIdentified(PlayerAlias alias)
{
var panel = GameObject.Find("APIs");
if (panel != null)
{
ResponseMessage.SetText($"Identified ({Talo.CurrentAlias.displayName})!");
ResponseMessage.SetText($"Identified ({alias.displayName})!");
panel.GetComponent<Image>().color = new Color(120 / 255f, 230 / 255f, 160 / 255f);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private void Awake()

if (Talo.CurrentAlias != null)
{
OnIdentified(Talo.CurrentPlayer);
OnIdentified(Talo.CurrentAlias);
}
}

Expand All @@ -32,7 +32,7 @@ private void OnDisable()
Talo.Saves.OnSaveChosen -= OnSaveChosen;
}

private async void OnIdentified(Player player)
private async void OnIdentified(PlayerAlias alias)
{
await Talo.Saves.GetSaves();
SetDocumentVisibility(loginUI, DisplayStyle.None);
Expand Down
Loading