예제 #1
0
 public void ReturnLogin()
 {
     this.requestMsgID = 0;
     this.requestSerialID = 0;
     this.requestMsg = null;
     this.waitingSend = false;
     this.showReconnect = false;
     this.Close();
     this.status = ClientSession.ESessionStatus.ESS_None;
     this.serverShutDown = false;
 }
예제 #2
0
 public void SendCreatePlayerMsg(int gender, string name)
 {
     this.status = ClientSession.ESessionStatus.ESS_Loading;
     this.timeout = Time.time + 30f;
     this.playerGender = gender;
     this.playerName = name;
     GameUIManager.mInstance.ShowIndicate();
     if (!this.SendPacket(103, new MC2S_CreatePlayer
     {
         Gender = gender,
         Name = name
     }))
     {
         global::Debug.LogFormat("Request Connect, IP = {0}, Port = {1}, Account = {2}, Key = {3}", new object[]
         {
             this.serverHost,
             this.serverPort,
             this.accountID,
             this.accountKey
         });
         this.waitingSend = false;
         this.RequestConnect();
     }
 }
예제 #3
0
 public void OnCreatePlayerError()
 {
     this.status = ClientSession.ESessionStatus.ESS_CreateChar;
     GameUIManager.mInstance.HideIndicate();
 }
예제 #4
0
 public void OnDataInit(bool versionInit, bool newPlayer)
 {
     this.status = ClientSession.ESessionStatus.ESS_Gaming;
     this.heartBeatTimer = Time.realtimeSinceStartup;
     this.heartBeatFrame = Time.frameCount;
     this.playerGender = -1;
     if (this.requestMsgID == 0 || !this.msgFlag.ContainsKey(this.requestMsgID) || !this.waitingSend)
     {
         GameUIManager.mInstance.HideIndicate();
     }
 }
예제 #5
0
 public void HandleEnterGame(MemoryStream stream)
 {
     MS2C_EnterGame mS2C_EnterGame = Serializer.NonGeneric.Deserialize(typeof(MS2C_EnterGame), stream) as MS2C_EnterGame;
     if (mS2C_EnterGame.Result != 0 && mS2C_EnterGame.Result != 2)
     {
         GameUIManager.mInstance.HideIndicate();
         if (mS2C_EnterGame.Result == 1 || mS2C_EnterGame.Result == 9 || mS2C_EnterGame.Result == 12 || mS2C_EnterGame.Result == 13)
         {
             SdkU3d.setPropStr("SESSION", string.Empty);
             SdkU3d.ntLogout();
         }
         if (mS2C_EnterGame.Result == 16)
         {
             string @string = Singleton<StringManager>.Instance.GetString("EnterR_39", new object[]
             {
                 mS2C_EnterGame.UID
             });
             GameMessageBox gameMessageBox = GameMessageBox.ShowMessageBox(@string, MessageBox.Type.OK, null);
             gameMessageBox.CanCloseByFadeBGClicked = false;
             GameMessageBox expr_1F2 = gameMessageBox;
             expr_1F2.OkClick = (MessageBox.MessageDelegate)Delegate.Combine(expr_1F2.OkClick, new MessageBox.MessageDelegate(gameMessageBox.OnServerMsgOKClicked));
         }
         else
         {
             GameMessageBox.ShowServerMessageBox("EnterR", mS2C_EnterGame.Result);
         }
         return;
     }
     this.SetCryptoKey(mS2C_EnterGame.CryptoKey);
     if (mS2C_EnterGame.UID != string.Empty && (mS2C_EnterGame.UID != this.accountID || mS2C_EnterGame.AccessToken != this.accountKey))
     {
         this.accountID = mS2C_EnterGame.UID;
         this.accountKey = mS2C_EnterGame.AccessToken;
         SdkU3d.setPropStr("UIN", this.accountID);
         SdkU3d.setPropStr("SESSION", this.accountKey);
     }
     if (this.newConnect)
     {
         string a = SdkU3d.getChannel();
         if (a == "pps")
         {
             SdkU3d.setUserInfo("USERINFO_HOSTID", "ppsmobile_s" + GameSetting.Data.ServerID.ToString());
         }
         else
         {
             SdkU3d.setUserInfo("USERINFO_HOSTID", GameSetting.Data.ServerID.ToString());
         }
         if (a != "caohua")
         {
             SdkU3d.ntGameLoginSuccess();
         }
     }
     GameSetting.Data.Account = this.accountID;
     GameAnalytics.SetAccount();
     GameSetting.Data.LastGMLogin = (mS2C_EnterGame.Privilege > 0);
     GameSetting.UpdateNow = true;
     this.Privilege = mS2C_EnterGame.Privilege;
     GameManager gameMgr = Globals.Instance.GameMgr;
     if (mS2C_EnterGame.Result == 0)
     {
         gameMgr.Status = GameManager.EGameStatus.EGS_Loading;
         if (this.newConnect)
         {
             this.newConnect = false;
             if (mS2C_EnterGame.GMAutoPatch)
             {
                 this.stopTimer = true;
                 gameMgr.ReCheckVersion(new Action(this.SendGetPlayerDataMsg));
                 return;
             }
         }
         this.SendGetPlayerDataMsg();
         return;
     }
     if (mS2C_EnterGame.Result == 2)
     {
         if (this.playerGender == 0 || this.playerGender == 1)
         {
             this.timeout = Time.time + 30f;
             MC2S_CreatePlayer mC2S_CreatePlayer = new MC2S_CreatePlayer();
             mC2S_CreatePlayer.Gender = this.playerGender;
             mC2S_CreatePlayer.Name = this.playerName;
             Globals.Instance.CliSession.Send(103, mC2S_CreatePlayer);
         }
         else
         {
             this.status = ClientSession.ESessionStatus.ESS_CreateChar;
             GameUIManager.mInstance.HideIndicate();
             if (gameMgr.Status == GameManager.EGameStatus.EGS_Login)
             {
                 gameMgr.Status = GameManager.EGameStatus.EGS_CreateChar;
                 if (mS2C_EnterGame.GMAutoPatch)
                 {
                     gameMgr.ReCheckVersion(delegate
                     {
                         GameUIManager.mInstance.LoadSessionScene<GUICreateCharacterScene>();
                     });
                 }
                 else
                 {
                     GameUIManager.mInstance.LoadSessionScene<GUICreateCharacterScene>();
                 }
             }
             else
             {
                 GameMessageBox.ShowServerMessageBox("EnterR", 38);
             }
         }
         return;
     }
 }
예제 #6
0
 public void HandleDisconnect(MemoryStream stream)
 {
     this.IsConnected = false;
     bool flag = false;
     switch (this.status)
     {
     case ClientSession.ESessionStatus.ESS_Connecting:
         this.HandleError(ClientSession.ESessionError.ESE_ConnectDisconnect, false);
         flag = true;
         break;
     case ClientSession.ESessionStatus.ESS_Loading:
         this.HandleError(ClientSession.ESessionError.ESE_LoadingDisconnect, false);
         flag = true;
         break;
     case ClientSession.ESessionStatus.ESS_Gaming:
         if (this.requestMsgID != 0)
         {
             this.HandleError(ClientSession.ESessionError.ESE_SendDisconnect, false);
             flag = true;
         }
         this.status = ClientSession.ESessionStatus.ESS_None;
         break;
     }
     global::Debug.Log(new object[]
     {
         "Disconnect!"
     });
     if (!flag && this.showReconnect)
     {
         NetworkMessageBox.ShowMessageBox(7);
     }
 }
예제 #7
0
 private void UpdateSessionStatus(float elapse)
 {
     switch (this.status)
     {
     case ClientSession.ESessionStatus.ESS_Connect:
         this.IsConnected = false;
         if (this.tcpClient.Connect(this.serverHost, this.serverPort))
         {
             this.status = ClientSession.ESessionStatus.ESS_Connecting;
             this.timeout = Time.time + 15f;
         }
         else
         {
             this.HandleError(ClientSession.ESessionError.ESE_RequestConnectError, true);
         }
         break;
     case ClientSession.ESessionStatus.ESS_Connecting:
         if (this.IsConnected)
         {
             this.status = ClientSession.ESessionStatus.ESS_Loading;
             this.timeout = Time.time + 30f;
             this.decryptKey = null;
             this.encryptKey = null;
             this.SendEnterGameMsg();
         }
         else if (Time.time > this.timeout)
         {
             this.HandleError(ClientSession.ESessionError.ESE_ConnectTimeout, true);
         }
         break;
     case ClientSession.ESessionStatus.ESS_Loading:
         if (this.stopTimer)
         {
             this.timeout += Time.deltaTime;
         }
         if (Time.time > this.timeout)
         {
             this.HandleError(ClientSession.ESessionError.ESE_LoadingTimeout, true);
         }
         break;
     case ClientSession.ESessionStatus.ESS_Gaming:
         if (this.waitingSend)
         {
             this.waitingSend = false;
             ushort msgID = this.requestMsgID;
             ushort msgSerialID = this.requestSerialID;
             object ojb = this.requestMsg;
             this.requestMsgID = 0;
             this.requestSerialID = 0;
             this.requestMsg = null;
             this.Send(msgID, ojb, msgSerialID);
         }
         else if (this.requestMsgID != 0 && Time.time - this.timeout > 15f)
         {
             this.HandleError(ClientSession.ESessionError.ESE_SendTimeout, true);
         }
         if (Time.realtimeSinceStartup - this.heartBeatTimer > 15f && Time.frameCount - this.heartBeatFrame > 300)
         {
             this.heartBeatTimer = Time.realtimeSinceStartup;
             this.heartBeatFrame = Time.frameCount;
             MC2S_HeartBeat ojb2 = new MC2S_HeartBeat();
             this.SendPacket(107, ojb2);
         }
         break;
     }
 }
예제 #8
0
 private void RequestConnect()
 {
     this.Close();
     this.status = ClientSession.ESessionStatus.ESS_Connect;
 }
예제 #9
0
 private void HandleError(ClientSession.ESessionError error, bool retry = false)
 {
     this.status = ClientSession.ESessionStatus.ESS_None;
     if (retry)
     {
         if (this.retryCount < 1)
         {
             this.retryCount++;
             if (this.requestMsgID != 0)
             {
                 this.waitingSend = true;
             }
             this.RequestConnect();
             GameUIManager.mInstance.ShowIndicate();
             return;
         }
         this.Close();
     }
     this.retryCount = 0;
     NetworkMessageBox.ShowMessageBox((int)error);
     GameUIManager.mInstance.HideIndicate();
 }