public void WemeReLogin() { //JSONObject authdataResult = JSONObject.Parse(((TextAsset)Resources.Load("JSONRequests/weme/authData")).text); Debug.Log( "Connect to login server... " + AsNetworkDefine.LOGIN_SERVER_IP + " " + AsNetworkDefine.LOGIN_SERVER_PORT); AsNetworkManager.Instance.ConnectToServer( AsNetworkDefine.LOGIN_SERVER_IP, AsNetworkDefine.LOGIN_SERVER_PORT, SOCKET_STATE.SS_LOGIN); if (true == AsNetworkManager.Instance.IsConnected()) { AsLoadingIndigator.Instance.ShowIndigator(""); string strAuthData = WemeManager.Instance.authData(); if (null == strAuthData) return; JSONObject jsonObject = JSONObject.Parse(strAuthData); JSONObject authDataJosn = jsonObject.GetObject("authData"); if( null == authDataJosn) return; body_CL_WEMELOGIN wemeLogin = new body_CL_WEMELOGIN(); JSONObject checkAuthJson = new JSONObject(); JSONObject recordJson = new JSONObject(); #if UNITY_EDITOR recordJson.Add("os", "window"); #elif UNITY_ANDROID recordJson.Add("os", "android"); #elif UNITY_IPHONE recordJson.Add("os", "ios"); #endif //2014.05.16 // if (WemeSdkManager.Instance.IsGuest) // { // recordJson.Add("platform", "guest"); // } // else // { recordJson.Add("platform", AsGameDefine.WEME_DOMAIN); // } if(authDataJosn["authProvider"].Str.CompareTo( "weme") == 0) { wemeLogin.eLoginType = (int)eLOGINTYPE.eLOGINTYPE_WEME; checkAuthJson.Add("wemeMemberNo", authDataJosn["wemeMemberNo"].Str); checkAuthJson.Add("accessToken", authDataJosn["accessToken"].Str); recordJson.Add("platform", AsGameDefine.WEME_DOMAIN); recordJson.Add("device", authDataJosn["uuid"].Str ); } else if(authDataJosn["authProvider"].Str.CompareTo("facebook") == 0) { wemeLogin.eLoginType = (int)eLOGINTYPE.eLOGINTYPE_FACEBOOK; checkAuthJson.Add("fbUserId", authDataJosn["fbUserId"].Str); checkAuthJson.Add("accessToken", authDataJosn["accessToken"].Str); recordJson.Add("platform", "facebook"); recordJson.Add("device", "" ); } else if( authDataJosn["authProvider"].Str.CompareTo( "google") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_GOOGLEPLUS; checkAuthJson.Add( "googleUserId", authDataJosn["googleUserId"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", "google"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "naver") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_NAVER; checkAuthJson.Add( "naverUserId", authDataJosn["naverUserId"].Str); checkAuthJson.Add( "naverAliasId", ""); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", "naver"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "band") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_NAVER_BAND; checkAuthJson.Add( "bandUserId", authDataJosn["bandUserId"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", "band"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "device") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_DEVICE; checkAuthJson.Add( "deviceId", authDataJosn["deviceId"].Str); checkAuthJson.Add( "deviceSeq", authDataJosn["deviceSeq"].Str); recordJson.Add( "platform", "device"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "yahoojp") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_YAHOOJP; checkAuthJson.Add( "yahoojpUserId", authDataJosn["yahoojpUserId"].Str); checkAuthJson.Add( "yahoojpIdToken", authDataJosn["yahoojpIdToken"].Str); checkAuthJson.Add( "yahoojpNonce", authDataJosn["yahoojpNonce"].Str); recordJson.Add( "platform", "yahoojp"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "twitter") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_TWITTER; checkAuthJson.Add( "twitterUserId", authDataJosn["twitterUserId"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); checkAuthJson.Add( "accessTokenSecret", authDataJosn["accessTokenSecret"].Str); checkAuthJson.Add( "consumerKey", authDataJosn["consumerKey"].Str); checkAuthJson.Add( "consumerSecret", authDataJosn["consumerSecret"].Str); recordJson.Add( "platform", "twitter"); recordJson.Add( "device", ""); } byte[] srcAuth = System.Text.UTF8Encoding.UTF8.GetBytes(checkAuthJson.ToString()); System.Buffer.BlockCopy(srcAuth, 0, wemeLogin.strCheckAuth, 0, srcAuth.Length); byte[] srcRecord = System.Text.UTF8Encoding.UTF8.GetBytes(recordJson.ToString()); System.Buffer.BlockCopy(srcRecord, 0, wemeLogin.strRecord, 0, srcRecord.Length); Debug.Log( "strCheckAuth()" + checkAuthJson.ToString() + "srcRecord" + recordJson.ToString()); wemeLogin.bIsGuest = false; wemeLogin.bIsAccountDeleteCancel = AsUserInfo.Instance.isAccountDeleteCancel; AsUserInfo.Instance.isAccountDeleteCancel = false; byte[] packet = wemeLogin.ClassToPacketBytes(); AsNetworkMessageHandler.Instance.Send(packet); WemeSdkManager.Instance.IsWithdrawLogin = true; } }
public void WemeLogin() { Debug.Log( "Connect to login server... " + ip + " " + AsNetworkDefine.LOGIN_SERVER_PORT); try { AsNetworkManager.Instance.ConnectToServer( IP, AsNetworkDefine.LOGIN_SERVER_PORT, SOCKET_STATE.SS_LOGIN); } catch( Exception e) { Debug.LogWarning( "WemeLogin : "******""); string strAuthData = WemeManager.Instance.authData(); if( null == strAuthData) { InitButtonState(); return; } JSONObject jsonObject = JSONObject.Parse( strAuthData); JSONObject authDataJosn = jsonObject.GetObject( "authData"); Debug.Log( "WemeLogin()strAuthData:"+ strAuthData ); if( null == authDataJosn) { InitButtonState(); Debug.Log( "WemeLogin()"+ jsonObject.ToString()); return; } body_CL_WEMELOGIN wemeLogin = new body_CL_WEMELOGIN(); JSONObject checkAuthJson = new JSONObject(); JSONObject recordJson = new JSONObject(); #if UNITY_EDITOR recordJson.Add( "os", "window"); #elif UNITY_ANDROID recordJson.Add( "os", "android"); #elif UNITY_IPHONE recordJson.Add( "os", "ios"); #endif //2014.05.16 //if( WemeSdkManager.Instance.IsGuest) // recordJson.Add( "platform", "guest"); //else recordJson.Add( "platform", AsGameDefine.WEME_DOMAIN); if( authDataJosn["authProvider"].Str.CompareTo( "weme") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_WEME; checkAuthJson.Add( "wemeMemberNo", authDataJosn["wemeMemberNo"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", AsGameDefine.WEME_DOMAIN); recordJson.Add( "device", authDataJosn["uuid"].Str); } else if( authDataJosn["authProvider"].Str.CompareTo( "facebook") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_FACEBOOK; checkAuthJson.Add( "fbUserId", authDataJosn["fbUserId"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", "facebook"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "google") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_GOOGLEPLUS; checkAuthJson.Add( "googleUserId", authDataJosn["googleUserId"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", "google"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "naver") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_NAVER; checkAuthJson.Add( "naverUserId", authDataJosn["naverUserId"].Str); checkAuthJson.Add( "naverAliasId", ""); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", "naver"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "band") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_NAVER_BAND; checkAuthJson.Add( "bandUserId", authDataJosn["bandUserId"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); recordJson.Add( "platform", "band"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "device") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_DEVICE; checkAuthJson.Add( "deviceId", authDataJosn["deviceId"].Str); checkAuthJson.Add( "deviceSeq", authDataJosn["deviceSeq"].Str); recordJson.Add( "platform", "device"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "yahoojp") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_YAHOOJP; checkAuthJson.Add( "yahoojpUserId", authDataJosn["yahoojpUserId"].Str); checkAuthJson.Add( "yahoojpIdToken", authDataJosn["yahoojpIdToken"].Str); checkAuthJson.Add( "yahoojpNonce", authDataJosn["yahoojpNonce"].Str); recordJson.Add( "platform", "yahoojp"); recordJson.Add( "device", ""); } else if( authDataJosn["authProvider"].Str.CompareTo( "twitter") == 0) { wemeLogin.eLoginType = ( int)eLOGINTYPE.eLOGINTYPE_TWITTER; checkAuthJson.Add( "twitterUserId", authDataJosn["twitterUserId"].Str); checkAuthJson.Add( "accessToken", authDataJosn["accessToken"].Str); checkAuthJson.Add( "accessTokenSecret", authDataJosn["accessTokenSecret"].Str); checkAuthJson.Add( "consumerKey", authDataJosn["consumerKey"].Str); checkAuthJson.Add( "consumerSecret", authDataJosn["consumerSecret"].Str); recordJson.Add( "platform", "twitter"); recordJson.Add( "device", ""); } byte[] srcAuth = System.Text.UTF8Encoding.UTF8.GetBytes( checkAuthJson.ToString()); System.Buffer.BlockCopy( srcAuth, 0, wemeLogin.strCheckAuth, 0, srcAuth.Length); byte[] srcRecord = System.Text.UTF8Encoding.UTF8.GetBytes( recordJson.ToString()); System.Buffer.BlockCopy( srcRecord, 0, wemeLogin.strRecord, 0, srcRecord.Length); Debug.Log( "strCheckAuth()" + checkAuthJson.ToString() + "srcRecord" + recordJson.ToString()); wemeLogin.bIsGuest = false; wemeLogin.bIsAccountDeleteCancel = AsUserInfo.Instance.isAccountDeleteCancel; AsUserInfo.Instance.isAccountDeleteCancel = false; byte[] packet = wemeLogin.ClassToPacketBytes(); AsNetworkMessageHandler.Instance.Send( packet); WemeSdkManager.Instance.IsWemeLogin = true; string resultString = WemeManager.Instance.isAllowPushMessage(); if( false == AsGameMain.GetOptionState( OptionBtnType.OptionBtnType_Push)) { if( true == WemeManager.isSuccess( resultString)) { bool allow = JSONObject.Parse( resultString).GetBoolean( "allow"); if( true == allow) WemeSdkManager.GetMainGameObject.setPushAllow(); } } else { if( true == WemeManager.isSuccess( resultString)) { bool allow = JSONObject.Parse( resultString).GetBoolean( "allow"); if( false == allow) WemeSdkManager.GetMainGameObject.setPushAllow(); } } AsPartyTrackManager.Instance.SetEvent(AsPartyTrackManager.ePartyTrackEvent.eCompletion_Loading); #if ( !UNITY_EDITOR && !UNITY_STANDALONE_OSX && !UNITY_STANDALONE_WIN) UserData.Instance.playerKey = WemeManager.getString( "playerKey", WemeManager.Instance.playerKey(), ""); #endif } }