private void TrySendToServer(List <MovementModel> gestureToSend) { Print($"Gesture capturing finished.{Environment.NewLine}Sending gesture to server."); var model = new LoggerModel { Movements = gestureToSend, Buttons = new List <ButtonModel>() }; var response = LoggerServerAPI.Lookup( model, new Dictionary <HttpStatusCode, Func <bool> > { { HttpStatusCode.OK, () => true }, { HttpStatusCode.NotFound, () => { ShowMenu("User not found.", false); return(false); } } }, exception => Print(exception.Message, LogType.Error)); if (response == null) { return; } ShowMenu($"Welcome user with ID {response.UserId}.", true); }
private IEnumerator SubmitUserName(string userName) { var response = LoggerServerAPI.PostUser( new UserRequestModel { UserName = userName }, new Dictionary <HttpStatusCode, Func <bool> > { { HttpStatusCode.OK, () => { keyboard.ShowSuccessMessage("Successfully sent."); return(true); } } }, exception => keyboard.ShowValidationMessage(exception.Message)); if (response == null) { yield break; } var configHolder = new GameObject("Registration Config"); var config = configHolder.AddComponent <RegistrationConfig>(); config.userName = userName; config.userId = response.UserId; yield return(new WaitForSeconds(2f)); SceneManager.LoadScene("Registration Logger"); _player.SetActive(true); }
private static List <List <MovementModel> > LoadGestures(string userId) { var movements = LoggerServerAPI.GetUserMovements( userId, null, exception => Debug.LogError(exception.Message)); if (movements != null) { return(movements .GroupBy(movement => movement.SessionId) .Select(group => group.ToList()) .OrderBy(gesture => Random.Range(0f, 1f)) .ToList()); } return(new List <List <MovementModel> >()); }
private void TrySendToServer(List <MovementModel> gestureToSend) { Print("Gesture capturing finished."); if (gestureToSend.Count < 1 && gestureToSend.Last().Timestamp < shortestGestureMiliseconds) { Print($"Gesture is too short. Please try again and hold trigger longer than {shortestGestureMiliseconds}ms.", LogType.Warning); return; } Print("Sending gesture to server."); var response = LoggerServerAPI.PostUserMovements( _userId, gestureToSend, new Dictionary <HttpStatusCode, Func <bool> > { { HttpStatusCode.Accepted, () => true }, { HttpStatusCode.OK, () => { _finished = true; return(true); } } }, exception => Print(exception.Message, LogType.Error)); if (response == null) { return; } Print($"Gesture sent successfully for {_userName}."); Print( _finished ? "Server has enough gestures, logging finished successfully." : "Please send more gestures."); }
public void Cancel() { var response = LoggerServerAPI.DeleteUserMovements( _userId, new Dictionary <HttpStatusCode, Func <bool> > { { HttpStatusCode.OK, () => true }, { HttpStatusCode.NotFound, () => true } }, exception => Print(exception.Message, LogType.Error)); if (response != null) { SceneManager.LoadScene("Main Menu"); } }