Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerManager SetProfileValues improvements #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 14 additions & 5 deletions Assets/Altzone/Scripts/ServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Altzone.Scripts.Model.Poco.Clan;
using Altzone.Scripts.GA;
using Altzone.Scripts.Model.Poco.Game;
using UnityEngine.Assertions;

/// <summary>
/// ServerManager acts as an interface between the server and the game.
Expand Down Expand Up @@ -199,18 +200,26 @@ public void LogOut()
}

/// <summary>
/// Sets values related to "Profile" received from server
/// Sets values related to player "Profile" received from server
/// </summary>
/// <param name="profileJSON">JSON object containing Profile info from server</param>
/// <remarks>
/// Profile and Player are not the same as Profile might hold personal information!
/// Profile and Player (<c>ServerPlayer</c>) are not the same as Profile might hold personal information!<br />
/// Player contains exclusively data related to in game Player.
/// </remarks>
public void SetProfileValues(JObject profileJSON)
{
AccessToken = profileJSON["accessToken"].ToString();
AccessTokenExpiration = int.Parse(profileJSON["tokenExpires"].ToString());
PlayerPrefs.SetString("playerId", profileJSON["Player"]["_id"].ToString());
var accessToken = profileJSON["accessToken"];
Assert.IsNotNull(accessToken);
AccessToken = (string)accessToken;

var tokenExpires = profileJSON["tokenExpires"];
Assert.IsNotNull(tokenExpires);
AccessTokenExpiration = tokenExpires.Value<int>();

var player = profileJSON["Player"];
Assert.IsNotNull(player);
PlayerPrefs.SetString("playerId", (string)player["_id"] ?? string.Empty);

//StartCoroutine(LogIn());
}
Expand Down