public new void PacketBytesToClass( byte[] data) { Type infotype = this.GetType(); FieldInfo headerinfo = null; int index = ParsePacketHeader( data); // nLastWorldIdx byte[] lastWorldIdx = new byte[ sizeof( Int32)]; headerinfo = infotype.GetField( "nLastWorldIdx", BINDING_FLAGS_PIG); Buffer.BlockCopy( data, index, lastWorldIdx, 0, sizeof( Int32)); headerinfo.SetValue( this, BitConverter.ToInt32( lastWorldIdx, 0)); index += sizeof( Int32); // nServerNewCnt byte[] serverNewCount = new byte[ sizeof( Int32)]; headerinfo = infotype.GetField( "nServerNewCnt", BINDING_FLAGS_PIG); Buffer.BlockCopy( data, index, serverNewCount, 0, sizeof( Int32)); headerinfo.SetValue( this, BitConverter.ToInt32( serverNewCount, 0)); index += sizeof( Int32); // nServerCnt byte[] serverCount = new byte[ sizeof( Int32)]; headerinfo = infotype.GetField( "nServerCnt", BINDING_FLAGS_PIG); Buffer.BlockCopy( data, index, serverCount, 0, sizeof( Int32)); headerinfo.SetValue( this, BitConverter.ToInt32( serverCount, 0)); index += sizeof( Int32); // iap ip byte[] szIAPIP = new byte[AsNetworkDefine.eIPADDRESS + 1]; headerinfo = infotype.GetField( "szIAPAgentIP", BINDING_FLAGS_PIG); Buffer.BlockCopy( data, index, szIAPIP, 0, AsNetworkDefine.eIPADDRESS + 1); headerinfo.SetValue( this, System.Text.ASCIIEncoding.ASCII.GetString( szIAPIP)); index += AsNetworkDefine.eIPADDRESS + 1; // iap domain byte[] szDomain = new byte[AsNetworkDefine.eDOMAIN + 1]; headerinfo = infotype.GetField("szIAPDomain", BINDING_FLAGS_PIG); Buffer.BlockCopy(data, index, szDomain, 0, AsNetworkDefine.eDOMAIN + 1); headerinfo.SetValue(this, System.Text.ASCIIEncoding.ASCII.GetString( szDomain)); index += AsNetworkDefine.eDOMAIN + 1; // iap port byte[] szIAPPort = new byte[sizeof( UInt16)]; headerinfo = infotype.GetField( "nIAPAgentPort", BINDING_FLAGS_PIG); Buffer.BlockCopy( data, index, szIAPPort, 0, sizeof( UInt16)); headerinfo.SetValue( this, BitConverter.ToUInt16( szIAPPort, 0)); index += sizeof( UInt16); AsNetworkDefine.IAPAGENT_SERVER_IP = szIAPAgentIP; AsNetworkDefine.IAPAGENT_DOMAIN = szIAPDomain; AsNetworkDefine.IAPAGENT_SERVER_PORT = nIAPAgentPort; //$yde Debug.Log( "AS_LC_SERVERLIST_COUNT::PacketBytesToClass: AsNetworkDefine.IAPAGENT_SERVER_IP = " + AsNetworkDefine.IAPAGENT_SERVER_IP); Debug.Log( "AS_LC_SERVERLIST_COUNT::PacketBytesToClass: AsNetworkDefine.IAPAGENT_DOMAIN = " + AsNetworkDefine.IAPAGENT_DOMAIN); Debug.Log( "AS_LC_SERVERLIST_COUNT::PacketBytesToClass: AsNetworkDefine.IAPAGENT_SERVER_PORT = " + AsNetworkDefine.IAPAGENT_SERVER_PORT); body = new AS_LC_SERVERLIST_BODY[ nServerCnt]; for( int i = 0; i < nServerCnt; i++) { body[i] = new AS_LC_SERVERLIST_BODY(); byte[] tmpData = new byte[AS_LC_SERVERLIST_BODY.size]; Buffer.BlockCopy( data, index, tmpData, 0, tmpData.Length); body[i].ByteArrayToClass( tmpData); index += AS_LC_SERVERLIST_BODY.size; } }
public void InsertData( AS_LC_SERVERLIST_BODY data) { dataList.Add( data); }
public static void SetServerListBody(AS_LC_SERVERLIST_BODY _body) { s_SelectedServerData = _body; }
public static void CancelStandbyDlg() { if( m_Modifier != null) m_Modifier( false); s_SelectedServerData = null; AsNetworkManager.Instance.InitSocket(); }
public static void ConnectionConfirmed()//$yde { if( s_ServerListStandbyDlg != null) Destroy( s_ServerListStandbyDlg.gameObject); AsLoadingIndigator.Instance.ShowIndigator( ""); if( false == AsUserInfo.Instance.isWemeCertified) { AS_CG_LOGIN gameLogin = new AS_CG_LOGIN( AsUserInfo.Instance.LoginUserUniqueKey, AsUserInfo.Instance.LoginUserSessionKey, AsNetworkDefine.PROTOCOL_VERSION);//$yde byte[] data = gameLogin.ClassToPacketBytes(); AsNetworkMessageHandler.Instance.Send( data); } else { body_CG_WEMELOGIN wemeLogin = new body_CG_WEMELOGIN(); wemeLogin.nUserUniqKey = AsUserInfo.Instance.LoginUserUniqueKey; Debug.Log( "AsUserInfo.Instance.LoginUserUniqueKey : " + AsUserInfo.Instance.LoginUserUniqueKey); byte[] src = System.Text.UTF8Encoding.UTF8.GetBytes( AsUserInfo.Instance.WemeAuthToken); System.Buffer.BlockCopy( src, 0, wemeLogin.strAccessToken, 0, src.Length); Debug.Log( "AsUserInfo.Instance.WemeAuthToken : " + AsUserInfo.Instance.WemeAuthToken); wemeLogin.nVersion = AsNetworkDefine.PROTOCOL_VERSION;//$yde wemeLogin.bIsGuest = WemeSdkManager.Instance.IsGuest;//2014.05.16 //wemeLogin.bIsGuest = WemeSdkManager.Instance.IsConfirmGuest; byte[] packet = wemeLogin.ClassToPacketBytes(); AsNetworkMessageHandler.Instance.Send( packet); } s_SelectedServerData = null; }
// bool CheckMaintenance() // { // StringBuilder sb = new StringBuilder(); // sb.AppendFormat( "{0}{1}&domain={2}&game={3}&version={4}", AsNetworkDefine.WemeGateBaseUrl, market, domain, AsGameDefine.GAME_CODE, AsGameDefine.BUNDLE_VERSION); // // WWW www = new WWW( sb.ToString()); // // yield return www; // while( false == www.isDone) {} // // if( null != www.error) // { // Debug.Log( "WemeGateManager ShutDown"); // AsUtil.ShutDown( string.Empty); // } // // JSONObject topObj = JSONObject.Parse( www.text); // www.Dispose(); // www = null; // // UInt64 curTime = UInt64.Parse( topObj[ "timestamp"].Str); // JSONObject maintenance = topObj.GetObject( "maintenance"); // if( null == maintenance) // return true; // // string maintenanceBegin = maintenance[ "begin"].Str; // string maintenanceEnd = maintenance[ "end"].Str; // UInt64 beginTime = UInt64.Parse( maintenanceBegin); // UInt64 endTime = UInt64.Parse( maintenanceEnd); // // if( ( curTime < beginTime) || ( curTime > endTime)) // return true; // // return false; // } public bool ConnectServer()//$yde { // if( s_SelectedServerData != null) // return false; // if( false == CheckMaintenance()) // return false; if( false == serverData.bPossibleCreate) { AsNotify.Instance.MessageBox( AsTableManager.Instance.GetTbl_String(126), AsTableManager.Instance.GetTbl_String(2037), AsNotify.MSG_BOX_TYPE.MBT_OK, AsNotify.MSG_BOX_ICON.MBI_NOTICE); return false; } string ip = System.Text.UTF8Encoding.UTF8.GetString( serverData.szIpaddress); AsNetworkManager.Instance.ConnectToServer( ip, serverData.nPort, SOCKET_STATE.SS_GAMESERVER); if( true == AsNetworkManager.Instance.IsConnected()) { Debug.Log( "Connect game server..."); Debug.Log( "AsUserInfo.Instance.isWemeCertified : " + AsUserInfo.Instance.isWemeCertified); s_SelectedServerData = serverData; body_CG_LOGIN_POSSIBLE possible = new body_CG_LOGIN_POSSIBLE(); byte[] data = possible.ClassToPacketBytes(); AsNetworkMessageHandler.Instance.Send( data); AsUserInfo.Instance.CurrentServerID = s_SelectedServerData.nWorldIdx; AsSocialManager.Instance.ServerName = AsUtil.GetRealString( System.Text.UTF8Encoding.UTF8.GetString( s_SelectedServerData.szServerName)); Debug.Log( "body_CG_LOGIN_POSSIBLE is send"); return true; } return false; }
private void FirstConnect( AS_LC_SERVERLIST_BODY serverData) { string ip = System.Text.UTF8Encoding.UTF8.GetString( serverData.szIpaddress); AsNetworkManager.Instance.ConnectToServer( ip, serverData.nPort, SOCKET_STATE.SS_GAMESERVER); if( true == AsNetworkManager.Instance.IsConnected()) { Debug.Log( "Connect game server..."); Debug.Log( "AsUserInfo.Instance.isWemeCertified : " + AsUserInfo.Instance.isWemeCertified); body_CG_LOGIN_POSSIBLE possible = new body_CG_LOGIN_POSSIBLE(); byte[] data = possible.ClassToPacketBytes(); AsNetworkMessageHandler.Instance.Send( data); AsUserInfo.Instance.CurrentServerID = serverData.nWorldIdx; AsSocialManager.Instance.ServerName = AsUtil.GetRealString( System.Text.UTF8Encoding.UTF8.GetString( serverData.szServerName)); Debug.Log("body_CG_LOGIN_POSSIBLE is send"); if( true == AssetbundleManager.Instance.useAssetbundle) { AssetbundleManager.Instance.SceneAssetbundleLoadCache( "CharacterSelect"); AssetbundleManager.Instance.SceneAssetbundleLoadCache( "CharacterCreate"); AssetbundleManager.Instance.SceneAssetbundleLoadCache( "ChannelSelect"); } isAutoServerSelected = true; } }