private void createSession() { byte[] emptyBody = Serial.toBSON(new { }); StartCoroutine(HTTPHelpers.post(url + "/api/v1/sessions?bson=true", emptyBody, store.accessToken, (data) => { sessionInfo.gameObject.SetActive(true); sessionBackground.gameObject.SetActive(true); openingInfo.gameObject.SetActive(false); loadingCircle.gameObject.SetActive(false); nameTitle.gameObject.SetActive(true); nameInput.gameObject.SetActive(true); try { SessionData responce = Serial.fromBSON <SessionData>(data); sessionInfo.text = sessionInfoSave + responce.id; sessionID = responce.id; start.gameObject.SetActive(true); } catch (Exception e) { showError(e.ToString()); } }, (error) => { showError(error); }) ); }
private void serializeCaptures(object data) { if (sendToConsole && !isSilent) { if (pairs.Length != 0) { Debug.Log(JsonConvert.SerializeObject(data)); } else { Debug.Log(JsonConvert.SerializeObject(data, Formatting.Indented)); } return; } byte[] bson = Serial.toBSON(data); openRequests++; float start = Time.realtimeSinceStartup; string requestPath = url + sessionPath + id + "?bson=true"; StartCoroutine(HTTPHelpers.post(requestPath, bson, store.accessToken, (responceData) => { openRequests--; responceCount++; float responceTime = Time.realtimeSinceStartup - start; averageResponceTime = (averageResponceTime * responceCount + responceTime) / (responceCount + 1); averageOpenRequests = (averageOpenRequests * responceCount + openRequests) / (responceCount + 1); minOpenRequests.Include(openRequests); maxOpenRequests.Include(openRequests); minResponceTime.Include(responceTime); maxResponceTime.Include(responceTime); }, (error) => { openRequests--; Debug.Log(error); }) ); }
private void onLoginClick() { urlTitle.gameObject.SetActive(false); urlInput.gameObject.SetActive(false); warningInfo.gameObject.SetActive(false); newSession.gameObject.SetActive(false); connectionInfo.gameObject.SetActive(true); loadingCircle.gameObject.SetActive(true); // Content of the body is ignored byte[] emptyBody = Serial.toBSON(new { }); url = urlInput.text.Trim('/'); StartCoroutine(HTTPHelpers.post(url + "/api/v1/authentication/claims?bson=true", emptyBody, string.Empty, (data) => { openingInfo.gameObject.SetActive(true); connectionInfo.gameObject.SetActive(false); try { ClaimData responce = Serial.fromBSON <ClaimData>(data); StartCoroutine(WaitThenOpen(responce)); } catch (Exception e) { sessionInfo.text = "Error deserializing BSON response: " + e; Debug.Log(e); newSession.gameObject.SetActive(true); } }, (error) => { showError(error); }) ); }