Skip to content
Snippets Groups Projects
Commit 8a7a6f94 authored by baletiballo's avatar baletiballo
Browse files

Trying to make scroll loading async. Doesn't quite work yet

parent 4c145a67
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@ public static GlobalBehaviour Instance
/// <summary> Default Setting for all JSONConvert operations </summary>
public static JsonSerializerSettings JsonConvertDefaultSettings = new() { MaxDepth = 256 };
private void Awake()
private void Start()
{
Instance = this;
if (Instance != this)
......@@ -64,8 +64,12 @@ private void Awake()
JsonConvert.DefaultSettings = () => JsonConvertDefaultSettings;
DontDestroyOnLoad(this);
GetScrollsfromServer();
GetContextfromServer();
InitiateScrolls = GetScrollsfromServer();
StartCoroutine(InitiateScrolls);
InitiateContext = GetContextfromServer();
StartCoroutine(InitiateContext);
}
//TODO: Move where appropiate
......@@ -75,12 +79,8 @@ private void Awake()
public static IEnumerator InitiateScrolls = IEnumeratorExtensions.yield_break;
public static bool AttemptScrollList = true; //false;
private void GetScrollsfromServer()
private IEnumerator GetScrollsfromServer()
{
StartCoroutine(InitiateScrolls = _GetScrollsfromServer());
IEnumerator _GetScrollsfromServer()
{
//Try /scroll/listall endpoint when scroll/list is not working
//UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/listall");
//Postman-Echo-Mock
......@@ -141,7 +141,7 @@ IEnumerator _GetScrollsfromServer()
System.DateTime parseTime = System.DateTime.UtcNow;
List<Scroll> _AvailableScrolls = JsonConvert.DeserializeObject<List<Scroll>>(jsonString);
System.DateTime processTime = System.DateTime.UtcNow;
AvailableScrolls = new();
foreach (Scroll scroll in _AvailableScrolls)
......@@ -156,20 +156,15 @@ IEnumerator _GetScrollsfromServer()
$"Processing\t{(System.DateTime.UtcNow - processTime).TotalMilliseconds}ms");
yield break;
}
}
public static FactRecorder Context = new();
public static IEnumerator InitiateContext = IEnumeratorExtensions.yield_break;
public static bool ContextLoaded = false;
public static bool AttemptContextLoad = true; //false;
private void GetContextfromServer()
private IEnumerator GetContextfromServer()
{
StartCoroutine(InitiateContext = _GetContextfromServer());
IEnumerator _GetContextfromServer()
{
ContextLoaded = false;
System.DateTime requestTime = System.DateTime.UtcNow;
......@@ -275,7 +270,6 @@ IEnumerator _GetContextfromServer()
ContextLoaded = true;
yield break;
}
}
/// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment