Ejemplo n.º 1
0
    public static ExceptionGame.ResponseCode Parse(int code)
    {
        ExceptionGame.ResponseCode result = ExceptionGame.ResponseCode.CODE_000;
        switch (code)
        {
        case 200:
            result = ExceptionGame.ResponseCode.CODE_200;
            break;

        case 400:
            result = ExceptionGame.ResponseCode.CODE_400;
            break;

        case 404:
            result = ExceptionGame.ResponseCode.CODE_404;
            break;
        }
        return(result);
    }
Ejemplo n.º 2
0
 public void LoginUser()
 {
     StartCoroutine(DB.GetInstance().LoginUser(user.text, pass.text));
     if (user.text != null && pass.text != null)
     {
         if (DB.GetInstance().GetResponseText() != null)
         {
             textMessages.text = LocaleManager.GetInstance().TranslateStr("CONNECTING_SERVER");
             user.interactable = false;
             pass.interactable = false;
             Debug.Log("aqui entra");
             JsonData response = DB.GetInstance().JSONResponse();
             ExceptionGame.ResponseCode code = ExceptionGame.Parse((int)response[DB.RESPONSE_LABEL]);
             string message;
             if (code != ExceptionGame.ResponseCode.CODE_200)
             {
                 user.interactable = true;
                 pass.interactable = true;
                 pass.text         = null;
                 if (code == ExceptionGame.ResponseCode.CODE_404)
                 {
                     Debug.Log("Conection Fail");
                     message = LocaleManager.GetInstance().TranslateStr("ERROR_USER_NOT_EXIST");
                 }
                 else
                 {
                     Debug.Log("FAIL TO CONNECT SERVER");
                     message = LocaleManager.GetInstance().TranslateStr("ERROR_UNABLE_TO_CONNECT_SERVER");
                 }
             }
             else
             {
                 message = LocaleManager.GetInstance().TranslateStr("INFO_USER_EXIST");
                 Controllers.GetInstance().HideFloatingLayouts();
                 StartCoroutine(StartSP());
             }
             Debug.Log("MSJ: " + message);
             textMessages.text = message;
         }
         DB.GetInstance().CloseDB();
     }
 }