IEnumerator Upload_OBJ_and_MLTFile(string uploadURL, string localOBJFilePath, string localMTLFilePath) { //TODO: OBJfile upload. WWW objFile = new WWW(localOBJFilePath); yield return(objFile); WWW mtlFile = new WWW(localMTLFilePath); yield return(mtlFile); WWWForm postForm = new WWWForm(); PlayRecordData playData = new PlayRecordData(GameStatusModel.trainee.getId(), GameStatusModel.assistant.id, contentsName, "0", "0", startTime, endTime); postForm.AddField("result", Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonUtility.ToJson(playData, true)))); postForm.AddField("title", Convert.ToBase64String(Encoding.UTF8.GetBytes(title))); postForm.AddBinaryData("obj", objFile.bytes, originFileName + ".obj"); postForm.AddBinaryData("mtl", mtlFile.bytes, originFileName + ".mtl"); WWW upload = new WWW(uploadURL, postForm); yield return(upload); if (upload.error == null) { Debug.Log(upload.text); } else { Debug.Log(upload.error); } progressText.text = "완료됨"; gameStopBtn.interactable = true; }
public void OnPlayEndButton() { //게임 기록 데이터 정리 및 전송.. endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (score != 0) { PlayRecordData data = new PlayRecordData(GameStatusModel.trainee.getId(), GameStatusModel.assistant.id, this.contentsName, this.level.ToString(), this.score.ToString(), this.startTime, this.endTime); PlayRecordDataServiceManager.SendPlayRecordData(data); } SceneManager.LoadScene("MainMenuScene2"); }
private IEnumerator WavfileUplaod() { rc.recState = "recUpload"; recStartBtn.interactable = false; recStopBtn.interactable = false; wavFilePath = Application.persistentDataPath + "\\" + originFileName + ".wav"; endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); WWW wavFile = new WWW("file:///" + wavFilePath); yield return(wavFile); Debug.Log(wavFile.bytes.Length); WWWForm postForm = new WWWForm(); PlayRecordData playData = new PlayRecordData(GameStatusModel.trainee.getId(), GameStatusModel.assistant.id, contentsName, "0", "0", startTime, endTime); postForm.AddField("result", Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonUtility.ToJson(playData, true)))); postForm.AddField("title", Convert.ToBase64String(Encoding.UTF8.GetBytes(title))); postForm.AddBinaryData("wav", wavFile.bytes, originFileName + ".wav"); WWW upload = new WWW(uploadURL, postForm); yield return(upload); recStartBtn.interactable = true; recStopBtn.interactable = false; gameStopBtn.interactable = true; if (upload.error == null) { Debug.Log(upload.text); } else { Debug.Log(upload.error); } recUploadText.text = "업로드 완료"; rc.recState = "idle"; }
static public bool SendPlayRecordData(PlayRecordData data) { bool isSuccess = false; var webAddr = "http://117.17.158.201:8080/vrain/client/record"; WWWForm form = new WWWForm(); form.AddField("result", Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonUtility.ToJson(data, true)))); WWW www = new WWW(webAddr, form); WaitForRequest(www); if (www.error == null) { UnityEngine.Debug.Log("msg send success"); isSuccess = true; } else { UnityEngine.Debug.Log("msg send fail"); isSuccess = false; } return(isSuccess); }