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

sending works correctly now but format/request is still wrong

parent 11b001a4
No related branches found
No related tags found
No related merge requests found
......@@ -41104,6 +41104,11 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2089306640899292912, guid: 4d99275c6663c25469ad3b65efcd4f5f,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.00035664605
objectReference: {fileID: 0}
- target: {fileID: 2524590709578595355, guid: 4d99275c6663c25469ad3b65efcd4f5f,
type: 3}
propertyPath: m_AnchorMax.x
......@@ -37,10 +37,11 @@ public static AddFactResponse sendAdd(string path, string body)
//Put constructor parses stringbody to byteArray internally (goofy workaround)
UnityWebRequest www = UnityWebRequest.Put(path, body);
www.method = UnityWebRequest.kHttpVerbPOST;
// www.SetRequestHeader("Content-Type", "application/json");
// www.timeout = 1;
www.SetRequestHeader("Content-Type", "application/json");
www.timeout = 1;
//TODO: implement real asynchronous communication ...
AsyncOperation op = www.Send();
AsyncOperation op = www.SendWebRequest();
while (!op.isDone) { }
if (www.isNetworkError || www.isHttpError)
{
......@@ -60,7 +61,7 @@ public class PointFact : Fact
{
public Vector3 Point;
public Vector3 Normal;
public string ConceptName = "point";
public PointFact(int i, Vector3 P, Vector3 N)
{
......@@ -75,12 +76,11 @@ public PointFact(int i, Vector3 P, Vector3 N)
new JSONManager.OMF(P.z)
};
JSONManager.MMTTerm tp = new JSONManager.OMA(new JSONManager.OMS(ConceptName), arguments);
JSONManager.MMTDeclaration mmtDecl = new JSONManager.MMTDeclaration()
{
label = "test", //TODO: rework label/id ?
tp = tp //JSONManager adds the id prefix
};
//OMS constructor generates full URI
JSONManager.MMTTerm tp = new JSONManager.OMS("point");
JSONManager.MMTTerm df = new JSONManager.OMA(new JSONManager.OMS("tuple"), arguments);
JSONManager.MMTDeclaration mmtDecl = new JSONManager.MMTDeclaration("test", tp, df);
string body = JSONManager.ToJson(mmtDecl);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress+"/fact/add", body);
......
......@@ -7,7 +7,15 @@
public static class JSONManager
{
public static string URIPrefix = "http://mathhub.info/MitM/core/geometry?3DGeometry?";
public static Dictionary<string, string> URIDictionary = new Dictionary<string, string> {
{"point", "http://mathhub.info/MitM/core/geometry?3DGeometry?point" },
{"tuple", "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Tuple"},
{"line", "http://mathhub.info/MitM/core/geometry?Geometry/Common?line_type" },
{"distance", "http://mathhub.info/MitM/core/geometry?Geometry/Common?lineOf" }
};
[JsonConverter(typeof(JsonSubtypes), "kind")]
public class MMTTerm
......@@ -32,9 +40,12 @@ public class OMS : MMTTerm
public string uri;
public string kind = "OMS";
public OMS(string uri)
public OMS(string uri, bool convertToURI = true)
{
this.uri = URIPrefix + uri;
if (convertToURI)
this.uri = URIDictionary[uri];
else
this.uri = uri;
}
}
......@@ -51,13 +62,13 @@ public OMF(float f)
}
}
/*
class DeclarationBody : MMTTerm
{
MMTTerm original;
MMTTerm simplified;
string kind = "O/S";
}
}*/
public class MMTDeclaration
......@@ -65,6 +76,13 @@ public class MMTDeclaration
public string label;
public MMTTerm tp;
public MMTTerm df;
public MMTDeclaration(string label, MMTTerm tp, MMTTerm df)
{
this.label = label;
this.tp = tp;
this.df = df;
}
}
public static MMTDeclaration FromJson(string json)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment