internal void handleSendData () { //yield return null; string _data = VRDataObjectBuilder.buildVRDataString(false); Debug.Log (_data); VRDataObject.clearAllData (); StartCoroutine (sendDataCo (_data)); /* if (Session.connectionActive) { //TODO: Wait for vr data to build //string _data = yield return VRDataObjectBuilder.buildVRDataString(false); string _data = VRDataObjectBuilder.buildVRDataString(false); Debug.Log (_data); VRDataObject.clearAllData (); StartCoroutine (sendDataCo (_data)); } else { string _data = VRDataObjectBuilder.buildVRDataString(true); Debug.Log (_data); VRDataObject.clearAllData (); }*/ }
public VRDataObject(string _modelType, Transform _targetObj, Dictionary <string, string> _args) { //Keep room for different models switch (_modelType) { case ("A"): objData = VRDataObjectBuilder.buildModel_A(_targetObj, _args); break; default: Debug.LogError("VR data model type not defined, check your VRDataObject"); break; } //HACK: Not handling async properly allDataObjs.Add(this); if(allDataObjs.Count >= OBJS_PER_REQUEST) { if (OnSendRequest != null) { Debug.Log ("Sufficient objects in data list, sending now."); OnSendRequest (); } } }
IEnumerator HTTPRequest(WWW www, string _flag){ yield return www; // check for errors if (www.error == null) { Session.connectionActive = true; msg = www.text; //Check type of request switch (_flag) { case ("initRequest"): Debug.Log ("API init success!"); canLook = true; //TODO: hook coroutine to event //Start listening to sendDataRequests //VRDataObject.OnSendRequest += handleSendData; VRDataObject.OnSendRequest += handleSendData; break; case("dataRequest"): Debug.Log ("Data sent successfully!\n" + VRDataObjectBuilder.buildVRDataString (false)); break; } } else { Debug.Log("Error: "+ www.error); Session.connectionActive = false; switch (_flag) { case ("initRequest"): OnConnectionUnavailable (); //HACK: Handle canLook differently in offline mode canLook = true; break; case("dataRequest"): //TODO: write to file break; } } }