// Insert 는 '생성' 작업에 주로 사용된다. public void InsertUserStatDataTable() { // Param은 뒤끝 서버와 통신을 할 떄 넘겨주는 파라미터 클래스 입니다. Param param = new Param(); BackendReturnObject BRO = Backend.GameData.Insert("UserStatTable", param); if (BRO.IsSuccess()) { Debug.Log("indate : " + BRO.GetInDate()); } else { switch (BRO.GetStatusCode()) { case "404": Debug.Log("존재하지 않는 tableName인 경우"); break; case "412": Debug.Log("비활성화 된 tableName인 경우"); break; case "413": Debug.Log("하나의 row( column들의 집합 )이 400KB를 넘는 경우"); break; default: Debug.Log("서버 공통 에러 발생: " + BRO.GetMessage()); break; } } }
// GPGS 로그인 private IEnumerator Login() { progressText.text = "구글 로그인 성공"; yield return(GameManager.YieldInstructionCache.WaitForEndOfFrame); // 이미 로그인 된 경우 if (Social.localUser.authenticated == true) { progressText.text = "구글 로그인 성공"; BackendReturnObject BRO = Backend.BMember.AuthorizeFederation(GetTokens(), FederationType.Google, "gpgs"); id = Social.localUser.id; if (BRO.GetStatusCode().Equals("403") && BRO.GetMessage().Equals("forbidden blocked user, 금지된 blocked user 입니다")) { blockText.text = BRO.GetErrorCode(); blockPopUp.SetActive(true); yield break; } ConfirmUser(); } else { Social.localUser.Authenticate((bool success) => { if (success) { progressText.text = "구글 로그인 성공"; // 로그인 성공 -> 뒤끝 서버에 획득한 구글 토큰으로 가입요청 BackendReturnObject BRO = Backend.BMember.AuthorizeFederation(GetTokens(), FederationType.Google, "gpgs"); id = Social.localUser.id; if (BRO.GetStatusCode().Equals("403") && BRO.GetMessage().Equals("Forbidden blocked user, 금지된 blocked user")) { blockText.text = BRO.GetErrorCode(); blockPopUp.SetActive(true); return; } ConfirmUser(); } else { progressText.text = "구글 로그인 실패"; // 로그인 실패 Debug.Log("Login failed for some reason"); } }); } Backend.Initialize(() => { if (Backend.IsInitialized) { Debug.Log(Backend.Utils.GetGoogleHash()); } else { Debug.Log("초기화실패"); } }); }
//table list Load public void OnClickGetTableList() { BackendReturnObject BRO = Backend.GameInfo.GetTableList(); if (BRO.IsSuccess()) { JsonData publics = BRO.GetReturnValuetoJSON()["publicTables"]; Debug.Log("public Tables--------------------------------"); foreach (JsonData row in publics) { Debug.Log(row.ToString()); } Debug.Log("Private Tables--------------------------------"); JsonData privates = BRO.GetReturnValuetoJSON()["privateTables"]; foreach (JsonData row in privates) { Debug.Log(row.ToString()); } } else { Debug.Log("서버 공통 에러 발생 : " + BRO.GetMessage()); } }
public void OnClickLogin() { BackendReturnObject BRO = Backend.BMember.CustomLogin(idInput.text, paInput.text); if (BRO.IsSuccess()) { BackEndGameInfo.Instance.OnClickPublicContents(); Debug.Log("로그인 완료 / 정보 로드"); } else { string error = BRO.GetStatusCode(); switch (error) { case "401": Debug.Log("아이디 또는 비밀번호가 틀렸다."); break; case "403": Debug.Log("차단된 유저" + BRO.GetStatusCode()); break; default: Debug.Log("서버 공통 에러 발생" + BRO.GetMessage()); break; } } }
public void OnClickSignUp() { BackendReturnObject BRO = Backend.BMember.CustomSignUp(idInput.text, paInput.text, "Test1"); if (BRO.IsSuccess()) { Debug.Log("회원가입 완료"); BackEndGameInfo.Instance.OnClickInsertData(); } else { string error = BRO.GetStatusCode(); switch (error) { case "409": Debug.Log("중복된 customId가 존재하는 경우"); break; default: Debug.Log("서버 공통 에러" + BRO.GetMessage()); break; } } }
private void CustomCallback(BackendReturnObject callback) { Debug.Log(callback); if (callback.IsSuccess()) { bro = callback; IsSuccess = true; } else { //string errCode = callback.GetErrorCode(); string msg = string.Empty; switch (int.Parse(callback.GetStatusCode())) { case 401: msg = callback.GetMessage().Contains("customId") ? "존재하지 않는 아이디입니다." : "잘못된 비밀번호 입니다."; break; case 409: msg = "중복된 아이디입니다."; break; case 403: // 차단 msg = callback.GetErrorCode(); break; default: msg = callback.GetMessage(); break; } if (msg.Contains("비밀번호")) { Dispatcher.Instance.Invoke(() => SetPWGuide(msg)); } else { Dispatcher.Instance.Invoke(() => SetIdGuide(msg)); } } }
private void CheckError(BackendReturnObject BRO) { switch (BRO.GetStatusCode()) { case "200": Debug.Log("해당 유저의 데이터가 테이블에 없습니다."); break; case "404": if (BRO.GetMessage().Contains("gamer not found")) { Debug.Log("gamerIndate가 존재하지 gamer의 indate인 경우"); } else if (BRO.GetMessage().Contains("table not found")) { Debug.Log("존재하지 않는 테이블"); } break; case "400": if (BRO.GetMessage().Contains("bad limit")) { Debug.Log("limit 값이 100이상인 경우"); } else if (BRO.GetMessage().Contains("bad table")) { //public Table 정보를 얻는 코드로 privte Table 에 접근했을 떄 또는 //private Table 정보를 얻는 코드로 public Table 에 접근했을 때 Debug.Log("요청한 코드와 테이블의 고액여부가 맞지 않습니다."); } break; case "412": Debug.Log("비활성화된 테이블입니다."); break; default: Debug.Log("서버 공통 에러 발생: " + BRO.GetMessage()); break; } }
void PrintData() { Backend.BMember.CustomLogin("admin", "admin"); BackendReturnObject UserDataBro = Backend.GameInfo.GetPublicContents("MaxScore"); if (UserDataBro.IsSuccess()) { int cnt = UserDataBro.GetReturnValuetoJSON()["rows"].Count; Debug.Log("DBcnt: " + cnt); for (int i = 0; i < cnt; i++) { string DBID = UserDataBro.GetReturnValuetoJSON()["rows"][i]["ID"]["S"].ToString(); string DBMaxscore = UserDataBro.GetReturnValuetoJSON()["rows"][i]["MaxScore"]["N"].ToString(); list.Add(Tuple.Create(DBID, DBMaxscore)); } list.Sort(delegate(Tuple <string, string> x, Tuple <string, string> y) { if (int.Parse(x.Item2) > int.Parse(y.Item2)) { return(-1); } else if (int.Parse(x.Item2) < int.Parse(y.Item2)) { return(1); } else { return(0); } }); int j = 0; foreach (Tuple <string, string> data in list) { texts[j].text = data.Item1; j++; if (j > 9) { break; } } } else { Debug.Log(UserDataBro.GetMessage()); } Backend.BMember.Logout(); }
public void OnClickGPSLogin() { BackendReturnObject BRO = Backend.BMember.AuthorizeFederation(GPGSGetTokens(), FederationType.Google, "gpgs로 만든계정"); if (BRO.IsSuccess()) { Debug.Log("구글 토큰으로 뒤끝서버 로그인 성공 - 동기방식"); switch (BRO.GetStatusCode()) { case "200": Debug.Log("로그인 성공 / InDate값을 불러옵니다."); BackEndGameInfo.Instance.OnClickPublicContents(); break; case "201": Debug.Log("회원가입 성공 / InDate값을 생성합니다."); BackEndGameInfo.Instance.OnClickInsertData(); break; } LoginScreen.Instance.NextScreen(); } else { LoginScreen.Instance.OpenLoginFailedPanel(); switch (BRO.GetStatusCode()) { case "200": Debug.Log("이미 회원가입된 회원"); break; case "403": Debug.Log("차단된 사용자 입니다. 차단 사유 : " + BRO.GetErrorCode()); break; default: Debug.Log("서버 공통 에러 발생" + BRO.GetMessage()); break; } } }
public void InsertOwnUnitTable() { // Param은 뒤끝 서버와 통신을 할 떄 넘겨주는 파라미터 클래스 입니다. GameObject[] Ally = GameObject.FindGameObjectsWithTag("Team"); //동료 숫자 파악. for (int i = 0; i < Ally.Length; i++) { if (Ally[i].gameObject.name != "player") { Param param = new Param(); param.Add("Name", Ally[i].gameObject.name); BackendReturnObject BRO = Backend.GameData.Insert("OwnUnitTable", param); if (BRO.IsSuccess()) { Debug.Log("indate : " + BRO.GetInDate()); } else { switch (BRO.GetStatusCode()) { case "404": Debug.Log("존재하지 않는 tableName인 경우"); break; case "412": Debug.Log("비활성화 된 tableName인 경우"); break; case "413": Debug.Log("하나의 row( column들의 집합 )이 400KB를 넘는 경우"); break; default: Debug.Log("서버 공통 에러 발생: " + BRO.GetMessage()); break; } } } } }
public void SignUp() { //BackendReturnObject bro = Backend.BMember.LoginWithTheBackendToken(); GenIDPW(); BackendReturnObject returnObject = Backend.BMember.CustomSignUp(PlayerPrefs.GetString(DesignConstStorage.PlayerCustomID), (PlayerPrefs.GetString(DesignConstStorage.PlayerCustomPW))); string sCode = returnObject.GetStatusCode(); switch (sCode) { case "409": SignUp(); break; case "401": //회원가입 하는데 비번이 틀림???? //리얼리?????????? Debug.LogError(sCode); break; case "403": ShowBlockUserInfo(); break; case "201": welcomeFalg = true; //WelcomeNewUser(); break; default: break; } loadingtext.text = returnObject.GetMessage(); }
public void BroChecker (string CallingName, BackendReturnObject BRO, System.Action SuccessCallback = null, System.Action FailedCallback = null) { if (BRO.IsSuccess()) { ////Debug.Log("BRO.IsSuccess() == true -> " + CallingName + " 성공: " // + BRO.GetStatusCode() + " // " // + BRO.GetErrorCode() + " // " // + BRO.GetMessage()); SuccessCallback?.Invoke(); } else { Debug.Log("BRO.IsSuccess() = false -> " + CallingName + " 실패: " + BRO.GetStatusCode() + " // " + BRO.GetErrorCode() + " // " + BRO.GetMessage()); FailedCallback?.Invoke(); } }
//구글 토큰으로 뒤끝 회원가입 및 로그인. public void GPGSLogin() { BackendReturnObject BRO = Backend.BMember.AuthorizeFederation(GetTokens(), FederationType.Google, "GPGS로 만든 계정."); if (BRO.IsSuccess()) //로그인 성공. { switch (BRO.GetStatusCode()) { case "200": Debug.Log("이미 회원가입 완료."); break; case "201": Debug.Log("신규 회원가입 완료."); gameObject.GetComponent <BackEndGameInfo>().InsertUserStatDataTable(); //유저 스탯 테이블 생성. gameObject.GetComponent <BackEndGameInfo>().InsertUserAssetDataTable(); //유저 자산 테이블 생성. gameObject.GetComponent <BackEndGameInfo>().InsertUnitCaptureCountTable(); //유저 유닛 포획 도감 테이블 생성. break; } //Managers.Scene.LoadScene(Define.Scene.Main); LoginCanvas.SetActive(false); TapCanvs.SetActive(true); } else //로그인 실패. { switch (BRO.GetStatusCode()) //실패 사유. { case "403": Debug.Log("차단 유저입니다. 차단 사유 : " + BRO.GetErrorCode()); break; default: Debug.Log("서버 공통 에러 발생. " + BRO.GetMessage()); break; } } }
public void OnClickInsertData() { Param param = new Param(); param.Add("stage1", 0); param.Add("stage2", 0); param.Add("stage3", 0); BackendReturnObject BRO = Backend.GameInfo.Insert("StageScore", param); if (BRO.IsSuccess()) { Debug.Log("새로운 데이터가 서버에 등록되었습니다! indate 값 : " + BRO.GetInDate()); OnClickPublicContents(); } else { switch (BRO.GetStatusCode()) { case "404": Debug.Log("존재하지 않는 tableName인 경우"); break; case "412": Debug.Log("비활성화 된 tableName인 경우"); break; case "413": Debug.Log("하나의 row(colum들의 집합)이 400KB를 넘는경우"); break; default: Debug.Log("서버 공통 에러 발생 : " + BRO.GetMessage()); break; } } }
void LoadData() { string isLogined = PlayerPrefs.GetString("IS_LOGINED"); Debug.Log("isLogined: " + isLogined); if (isLogined.Equals("false")) { return; } MusicScoredata = new List <Tuple <string, string> >(); Debug.Log("load data"); BackendReturnObject UserDataBro = Backend.GameInfo.GetPrivateContents("ScoreTable"); if (UserDataBro.IsSuccess()) { Debug.Log("db success"); int cnt = UserDataBro.GetReturnValuetoJSON()["rows"].Count; for (int i = 0; i < cnt; i++) { string DBmusic = UserDataBro.GetReturnValuetoJSON()["rows"][i]["Music"]["S"].ToString(); string DBscore = UserDataBro.GetReturnValuetoJSON()["rows"][i]["Score"]["S"].ToString(); if (DBmusic.Equals("Under The Sunshine")) { scores[0].text = string.Format(Format, DBscore); } else if (DBmusic.Equals("axion")) { scores[1].text = string.Format(Format, DBscore); } else if (DBmusic.Equals("Blueming")) { scores[2].text = string.Format(Format, DBscore); } else if (DBmusic.Equals("Sugar")) { scores[3].text = string.Format(Format, DBscore); } else if (DBmusic.Equals("Adda")) { scores[4].text = string.Format(Format, DBscore); } } } else { Debug.Log(UserDataBro.GetMessage()); } //BackendAsyncClass.BackendAsync(Backend.GameInfo.GetPrivateContents, "ScoreTable", UserDataBro => //{ // Debug.Log("db success"); // if (UserDataBro.IsSuccess()) // { // int cnt = UserDataBro.GetReturnValuetoJSON()["rows"].Count; // for (int i = 0; i < cnt; i++) // { // string DBmusic = UserDataBro.GetReturnValuetoJSON()["rows"][i]["Music"]["S"].ToString(); // string DBscore = UserDataBro.GetReturnValuetoJSON()["rows"][i]["Score"]["S"].ToString(); // if(DBmusic.Equals("Under_the_sunshine")) // { // scores[0].text = string.Format(Format, DBscore); // } // else if (DBmusic.Equals("Axion")) // { // scores[1].text = string.Format(Format, DBscore); // } // else if (DBmusic.Equals("Blueming")) // { // scores[2].text = string.Format(Format, DBscore); // } // else if (DBmusic.Equals("Sugar")) // { // scores[3].text = string.Format(Format, DBscore); // } // else if (DBmusic.Equals("Adda")) // { // scores[4].text = string.Format(Format, DBscore); // } // } // } // else // { // Debug.Log(UserDataBro.GetMessage()); // } //}); }
private void GoogleAuth(System.Action loginAction) { if (PlayGamesPlatform.Instance.localUser.authenticated == false) { Social.localUser.Authenticate(success => { if (success == false) { Debug.Log("구글 로그인 실패"); return; } /*a * // 로그인이 성공되었습니다. * Debug.Log("GetIdToken - " + PlayGamesPlatform.Instance.GetIdToken()); * Debug.Log("Email - " + ((PlayGamesLocalUser)Social.localUser).Email); * Debug.Log("GoogleId - " + Social.localUser.id); * Debug.Log("UserName - " + Social.localUser.userName); * Debug.Log("UserName - " + PlayGamesPlatform.Instance.GetUserDisplayName());*/ BackendReturnObject BRO = Backend.BMember.AuthorizeFederation(GetTokens(), FederationType.Google, "gpgs로 만든계정"); if (BRO.IsSuccess()) { Debug.Log("구글 로그인 동기화 성공"); BackendAsyncClass.BackendAsync(Backend.BMember.GetUserInfo, (callback1) => { if (callback1.IsSuccess()) { JsonData json = callback1.GetReturnValuetoJSON()["row"]; if (json["nickname"] != null) { string nickName = json["nickname"].ToString(); UserInfo.instance.nickname = nickName; string indate = json["inDate"].ToString(); Debug.Log("로그인 성공 닉네임 : " + nickName); PlayerPrefs.SetString("login", "Google"); loginAction(); //lobbyLoding.Loading(); } else { BackendReturnObject servertime = Backend.Utils.GetServerTime(); string time = servertime.GetReturnValuetoJSON()["utcTime"].ToString(); DateTime parsedDate = DateTime.Parse(time); string nickname = parsedDate.Year.ToString() + parsedDate.Month.ToString() + parsedDate.Day.ToString() + parsedDate.Hour.ToString() + parsedDate.Minute.ToString() + parsedDate.Second.ToString() + UnityEngine.Random.Range(0, 1000).ToString(); BackendAsyncClass.BackendAsync(Backend.BMember.CreateNickname, nickname, (callback2) => { if (callback2.IsSuccess()) { Debug.Log("닉네임 만들기 성공"); UserInfo.instance.nickname = nickname; PlayerPrefs.SetString("login", "Google"); loginAction(); } else { switch (callback2.GetStatusCode()) { case "400": Debug.Log("빈 닉네임으로 생성"); Debug.Log("또는 20자 이상의 닉네임"); Debug.Log("닉네임 앞 뒤 공백이 있는 경우"); Debug.Log("에러 메세지" + callback2.GetMessage()); break; case "409": Debug.Log("이미 중복된 닉네임"); break; } } }); } } else { Debug.Log(callback1.GetErrorCode()); } }); } else { Debug.Log("구글 로그인 동기화 실패"); Debug.Log(BRO.GetStatusCode()); Debug.Log(BRO.GetMessage()); switch (BRO.GetStatusCode()) { case "200": Debug.Log("이미 회원가입된 회원"); break; case "403": Debug.Log("차단된 사용자 입니다. 차단 사유 : " + BRO.GetErrorCode()); break; } } }); } else { Debug.Log("bb"); BackendReturnObject BRO = Backend.BMember.AuthorizeFederation(GetTokens(), FederationType.Google, "gpgs로 만든계정"); if (BRO.IsSuccess()) { Debug.Log("구글 로그인 동기화 성공"); BackendAsyncClass.BackendAsync(Backend.BMember.GetUserInfo, (callback1) => { if (callback1.IsSuccess()) { JsonData json = callback1.GetReturnValuetoJSON()["row"]; if (json["nickname"] != null) { string nickName = json["nickname"].ToString(); string indate = json["inDate"].ToString(); Debug.Log("로그인 성공 닉네임 : " + nickName); PlayerPrefs.SetString("login", "Google"); loginAction(); //lobbyLoding.Loading(); } else { BackendReturnObject servertime = Backend.Utils.GetServerTime(); string time = servertime.GetReturnValuetoJSON()["utcTime"].ToString(); DateTime parsedDate = DateTime.Parse(time); string nickname = parsedDate.Year.ToString() + parsedDate.Month.ToString() + parsedDate.Day.ToString() + parsedDate.Hour.ToString() + parsedDate.Minute.ToString() + parsedDate.Second.ToString() + UnityEngine.Random.Range(0, 1000).ToString(); BackendAsyncClass.BackendAsync(Backend.BMember.CreateNickname, nickname, (callback2) => { if (callback2.IsSuccess()) { Debug.Log("닉네임 만들기 성공"); PlayerPrefs.SetString("login", "Google"); loginAction(); } else { switch (callback2.GetStatusCode()) { case "400": Debug.Log("빈 닉네임으로 생성"); Debug.Log("또는 20자 이상의 닉네임"); Debug.Log("닉네임 앞 뒤 공백이 있는 경우"); Debug.Log("에러 메세지" + callback2.GetMessage()); break; case "409": Debug.Log("이미 중복된 닉네임"); break; } } }); } } else { Debug.Log(callback1.GetErrorCode()); } }); } else { Debug.Log("구글 로그인 동기화 실패"); Debug.Log(BRO.GetStatusCode()); Debug.Log(BRO.GetMessage()); switch (BRO.GetStatusCode()) { case "200": Debug.Log("이미 회원가입된 회원"); break; case "403": Debug.Log("차단된 사용자 입니다. 차단 사유 : " + BRO.GetErrorCode()); break; } } } }