登录调整 IPart组件添加Connect成对方法
parent
35c41c2bad
commit
713b1f9d50
|
|
@ -90,20 +90,43 @@ namespace Gameplay.Net
|
|||
m_Parts[i].OnLoginOK();
|
||||
}
|
||||
}
|
||||
if (!_isReConnecting)
|
||||
{
|
||||
// if (!GuideManager.Instance.BeginGuide())
|
||||
// GameStateManager.Instance.ChangeState(new GameStateMainScene(true));
|
||||
//
|
||||
//if (!GameStartLoading.newMethodLogin)
|
||||
//{
|
||||
|
||||
OnEnterGame();
|
||||
//}
|
||||
GameSettingManager.Instance.Init();
|
||||
}
|
||||
//if (!_isReConnecting)
|
||||
//{
|
||||
// // if (!GuideManager.Instance.BeginGuide())
|
||||
// // GameStateManager.Instance.ChangeState(new GameStateMainScene(true));
|
||||
// //
|
||||
//if (!GameStartLoading.newMethodLogin)
|
||||
//{
|
||||
// OnEnterGame();
|
||||
//}
|
||||
GameSettingManager.Instance.Init();
|
||||
// }
|
||||
EventManager.Instance.Send(EventManager.EventName.LoginComplete);
|
||||
LoginController.Instance.OnLoginOK();
|
||||
|
||||
OnConnectOK();
|
||||
}
|
||||
|
||||
public void OnConnectOK()
|
||||
{
|
||||
for (int i = 0; i < (int)PartID.Max; i++)
|
||||
{
|
||||
if (m_Parts[i] != null)
|
||||
{
|
||||
m_Parts[i].OnConnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDisConnect()
|
||||
{
|
||||
for (int i = 0; i < (int)PartID.Max; i++)
|
||||
{
|
||||
if (m_Parts[i] != null)
|
||||
{
|
||||
m_Parts[i].OnDisconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -58,31 +58,32 @@ namespace Gameplay.Net
|
|||
|
||||
public override void Update()
|
||||
{
|
||||
switch(m_nStatus)
|
||||
switch (m_nStatus)
|
||||
{
|
||||
case CheckStatus.Start:
|
||||
{
|
||||
var current = Time.realtimeSinceStartup;
|
||||
if(current > m_fCheckTime + 3) // 3秒还没回来心跳,直接断开重连
|
||||
case CheckStatus.Start:
|
||||
{
|
||||
NetManager.Instance.CloseClient();
|
||||
DoRelogin();
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
var current = Time.realtimeSinceStartup;
|
||||
if (current > m_fCheckTime + 3) // 3秒还没回来心跳,直接断开重连
|
||||
{
|
||||
NetManager.Instance.CloseClient();
|
||||
Actor.Instance.OnDisConnect();
|
||||
DoRelogin();
|
||||
|
||||
case CheckStatus.Relogin:
|
||||
{
|
||||
var current = Time.realtimeSinceStartup;
|
||||
if(current > m_fCheckTime + 5) // 等待5秒之后再重连
|
||||
{
|
||||
DebugUtil.Log("LoginStatusOk go status relogin");
|
||||
Actor.Instance.Login.NextStatus = LoginStatusID.Relogin;
|
||||
m_nStatus = CheckStatus.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case CheckStatus.Relogin:
|
||||
{
|
||||
var current = Time.realtimeSinceStartup;
|
||||
if (current > m_fCheckTime + 5) // 等待5秒之后再重连
|
||||
{
|
||||
DebugUtil.Log("LoginStatusOk go status relogin");
|
||||
Actor.Instance.Login.NextStatus = LoginStatusID.Relogin;
|
||||
m_nStatus = CheckStatus.None;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ namespace Gameplay.Net
|
|||
private void OnEventError(uint nNetID)
|
||||
{
|
||||
DebugUtil.LogError("LoginStatusOk OnEventError, id={0}", nNetID);
|
||||
|
||||
Actor.Instance.OnDisConnect();
|
||||
DoRelogin();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace Gameplay.Net
|
|||
{
|
||||
DebugUtil.Log("LoginStatusRelogin OnGameLoginResult Success");
|
||||
Actor.Instance.Login.NextStatus = LoginStatusID.Ok;
|
||||
Actor.Instance.OnLoginOK();
|
||||
Actor.Instance.OnConnectOK();//OnLoginOK();
|
||||
GameClientReconnect.EndReconnect();
|
||||
GameClientReconnect.CloseReconnectConfirm();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ namespace Gameplay.Net
|
|||
public virtual PartID ID { get; }
|
||||
public virtual void Init() { } // 初始化
|
||||
public virtual void OnLoginOK() { } // 登录成功后被调用
|
||||
public virtual void OnConnect() { } // 连接成功后被调用
|
||||
public virtual void OnDisconnect() { } // 断开连接时被调用
|
||||
public abstract void OnLogout(); // 退出游戏时被调用,比如切换账号时
|
||||
public virtual void Update() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ namespace Gameplay.Net
|
|||
CurrentStatus.Login();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 服务器强制下线
|
||||
/// </summary>
|
||||
/// <param name="nReason"></param>
|
||||
public void OnServerDisconnect(int nReason)
|
||||
{
|
||||
DebugUtil.LogError("PartLogin OnServerDisconnect nReason={0}", nReason);
|
||||
|
|
@ -141,11 +145,12 @@ namespace Gameplay.Net
|
|||
DebugUtil.Log("服务器断开连接!当前处于防沉迷限制");
|
||||
UI_LongTipController.Open(onClose: () =>
|
||||
{
|
||||
Actor.Instance.OnDisConnect();
|
||||
var curState = GameStateManager.Instance.GetCurState();
|
||||
if (curState is not GameStateStart)
|
||||
{
|
||||
GameStateManager.Instance.ChangeState(new GameStateStart());
|
||||
}
|
||||
}
|
||||
Actor.Instance.OnLogout();
|
||||
}).Forget();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
BindButton(Button_AccountLogin_1, () => SetLoginType(LoginType.Account));
|
||||
BindButton(Button_VerifyCodeLogin_1, () => SetLoginType(LoginType.PhoneCode));
|
||||
BindButton(Button_Login_1, OnButtonLogin);
|
||||
BindButton(Button_UserCenter, OnCancelCurConnect);
|
||||
BindButton(Button_UserCenter, ShowLoginPanel);
|
||||
BindButton(Button_Notice, OnNoticeClick);
|
||||
|
||||
BindButton(Button_StartGame, OnStartGame);
|
||||
|
|
@ -772,13 +772,16 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
/// </summary>
|
||||
void OnCancelCurConnect()
|
||||
{
|
||||
//if (LoginController.Instance.IsLogin)//TODO 点开用户中心退出原先账号是否需要断开连接
|
||||
//{
|
||||
// DebugUtil.Log("登出!断开连接");
|
||||
// Actor.Instance.OnLogout();
|
||||
// //NetManager.Instance.CloseClient();
|
||||
// //loginOK = false;
|
||||
//}
|
||||
if (LoginController.Instance.IsLogin)//TODO 点开用户中心退出原先账号是否需要断开连接
|
||||
{
|
||||
DebugUtil.Log("登出!断开连接");
|
||||
Actor.Instance.OnDisConnect();
|
||||
Actor.Instance.OnLogout();
|
||||
}
|
||||
ShowLoginPanel();
|
||||
}
|
||||
void ShowLoginPanel()
|
||||
{
|
||||
if (loginSaveData.LoginByPhone)
|
||||
{
|
||||
SetLoginType(LoginType.PhoneCode);
|
||||
|
|
@ -787,7 +790,7 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
{
|
||||
SetLoginType(LoginType.Account);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async void OnNoticeClick()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue