Skip to content
Snippets Groups Projects
Commit 0fff99bd authored by Richard Marcus's avatar Richard Marcus
Browse files

fact creation now works without server

parent 70ccace6
Branches
No related tags found
No related merge requests found
...@@ -74,4 +74,6 @@ public class SignalEvent : UnityEvent { ...@@ -74,4 +74,6 @@ public class SignalEvent : UnityEvent {
//Global List of Facts //Global List of Facts
public static List<Fact> Facts = new List<Fact>(); public static List<Fact> Facts = new List<Fact>();
public static bool ServerRunning = false;
} }
...@@ -27,18 +27,24 @@ public class AddFactResponse ...@@ -27,18 +27,24 @@ public class AddFactResponse
public static AddFactResponse sendAdd(string path, string body) public static AddFactResponse sendAdd(string path, string body)
{ {
if (!CommunicationEvents.ServerRunning)
{
Debug.LogWarning("Server not running");
return new AddFactResponse();
}
Debug.Log(body); Debug.Log(body);
//Put constructor parses stringbody to byteArray internally (goofy workaround) //Put constructor parses stringbody to byteArray internally (goofy workaround)
UnityWebRequest www = UnityWebRequest.Put(path, body); UnityWebRequest www = UnityWebRequest.Put(path, body);
www.method = UnityWebRequest.kHttpVerbPOST; www.method = UnityWebRequest.kHttpVerbPOST;
www.SetRequestHeader("Content-Type", "application/json"); www.SetRequestHeader("Content-Type", "application/json");
www.timeout = 1;
//TODO: implement real asynchronous communication ...
AsyncOperation op = www.Send(); AsyncOperation op = www.Send();
while (!op.isDone) { } while (!op.isDone) { }
if (www.isNetworkError || www.isHttpError) if (www.isNetworkError || www.isHttpError)
{ {
Debug.Log(www.error); Debug.LogWarning(www.error);
return null; return new AddFactResponse();
} }
else else
{ {
......
...@@ -60,10 +60,11 @@ IEnumerator getScrollsfromServer() { ...@@ -60,10 +60,11 @@ IEnumerator getScrollsfromServer() {
yield return request.Send(); yield return request.Send();
if (request.isNetworkError || request.isHttpError) if (request.isNetworkError || request.isHttpError)
{ {
Debug.LogError(request.error); Debug.LogWarning(request.error);
} }
else else
{ {
CommunicationEvents.ServerRunning = true;
string jsonString = request.downloadHandler.text; string jsonString = request.downloadHandler.text;
buildScrollSelection(jsonString); buildScrollSelection(jsonString);
} }
......
...@@ -11,7 +11,7 @@ public class StartServer : MonoBehaviour ...@@ -11,7 +11,7 @@ public class StartServer : MonoBehaviour
[SerializeField] [SerializeField]
TMPro.TextMeshProUGUI WaitingText; TMPro.TextMeshProUGUI WaitingText;
bool ServerRunning = false;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
...@@ -20,7 +20,7 @@ void Start() ...@@ -20,7 +20,7 @@ void Start()
void PrepareGame() void PrepareGame()
{ {
WaitingText.text = "Press any key to start the game"; WaitingText.text = "Press any key to start the game";
ServerRunning= true; CommunicationEvents.ServerRunning= true;
UnityEngine.Debug.Log("server fin"); UnityEngine.Debug.Log("server fin");
} }
...@@ -181,7 +181,7 @@ IEnumerator ServerRoutine() ...@@ -181,7 +181,7 @@ IEnumerator ServerRoutine()
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(ServerRunning && Input.anyKey) if(CommunicationEvents.ServerRunning && Input.anyKey)
{ {
SceneManager.LoadScene(1); SceneManager.LoadScene(1);
} }
......
...@@ -28366,7 +28366,8 @@ MonoBehaviour: ...@@ -28366,7 +28366,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 38cd422d38f88564e81d012b615cc77a, type: 3} m_Script: {fileID: 11500000, guid: 38cd422d38f88564e81d012b615cc77a, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
ToolMode: 4 id: 0
UiName:
Sprite: {fileID: 21300000, guid: d456617ba2282854d9570dcebcc2b279, type: 3} Sprite: {fileID: 21300000, guid: d456617ba2282854d9570dcebcc2b279, type: 3}
FactManager: {fileID: 0} FactManager: {fileID: 0}
ignoreLayerMask: ignoreLayerMask:
...@@ -40563,6 +40564,11 @@ PrefabInstance: ...@@ -40563,6 +40564,11 @@ PrefabInstance:
propertyPath: ignoreLayerMask.m_Bits propertyPath: ignoreLayerMask.m_Bits
value: 31232 value: 31232
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 729203331, guid: 2ba8d552442ba664e8e567adee683a11, type: 3}
propertyPath: Sprite
value:
objectReference: {fileID: 21300000, guid: 644edf8b3fa05da418500a0e9dd10820,
type: 3}
- target: {fileID: 1085307962, guid: 2ba8d552442ba664e8e567adee683a11, type: 3} - target: {fileID: 1085307962, guid: 2ba8d552442ba664e8e567adee683a11, type: 3}
propertyPath: GadgetUI propertyPath: GadgetUI
value: value:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment