From bb08fcfe2303ecf2255ea63ca6b66f9d533fd518 Mon Sep 17 00:00:00 2001
From: MaZiFAU <63099053+MaZiFAU@users.noreply.github.com>
Date: Tue, 19 Sep 2023 16:36:48 +0200
Subject: [PATCH] Bugfix: EternalLoop if Server not found

---
 .../FactHandling/Facts/Fact.cs                | 23 +++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs
index 84fcffdb..ad15c40e 100644
--- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs
+++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs
@@ -480,7 +480,8 @@ static string _SendAdd(string path, string body)//, Action<string> uriCallback)
             UnityWebRequestAsyncOperation web =
                 www.SendWebRequest();
 
-            while (!web.isDone) ;
+            while (!web.isDone // not enough as querry
+                 && www.result == UnityWebRequest.Result.InProgress) ;
 
             if (www.result == UnityWebRequest.Result.ConnectionError
              || www.result == UnityWebRequest.Result.ProtocolError)
@@ -489,20 +490,18 @@ static string _SendAdd(string path, string body)//, Action<string> uriCallback)
                 //uriCallback(null);
                 return null; // yield break;
             }
-            else
-            {
-                while (!www.downloadHandler.isDone)
-                    //yield return null
-                    ;
 
-                FactReference res = JsonUtility.FromJson<FactReference>(www.downloadHandler.text);
+            while (!www.downloadHandler.isDone)
+                //yield return null
+                ;
 
-                if (CommunicationEvents.VerboseURI)
-                    Debug.Log("Server added Fact:\n" + res.uri);
+            FactReference res = JsonUtility.FromJson<FactReference>(www.downloadHandler.text);
 
-                //uriCallback(res.uri);
-                return res.uri; // yield break;
-            }
+            if (CommunicationEvents.VerboseURI)
+                Debug.Log("Server added Fact:\n" + res.uri);
+
+            //uriCallback(res.uri);
+            return res.uri; // yield break;
         }
     }
 
-- 
GitLab