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