AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/Manager/UserDataManager.cs

58 lines
1.4 KiB
C#
Raw Permalink Normal View History

2024-06-28 18:08:25 +08:00
using AxibugEmuOnline.Client.ClientCore;
namespace AxibugEmuOnline.Client.Manager
{
public class UserDataBase
{
public long UID { get; set; }
public string Account { get; set; }
}
public class MainUserDataBase : UserDataBase
{
public bool IsLoggedIn { get; set; } = false;
}
public class UserDataManager
{
public UserDataManager()
{
//注册重连成功事件,以便后续自动登录
App.network.OnReConnected += OnReConnected;
2024-06-28 18:08:25 +08:00
}
2024-08-16 10:20:00 +08:00
public MainUserDataBase userdata { get; private set; } = new MainUserDataBase();
2024-06-28 18:08:25 +08:00
public bool IsLoggedIn => userdata.IsLoggedIn;
2024-08-16 10:20:00 +08:00
public void InitMainUserData(string UName, long UID)
2024-06-28 18:08:25 +08:00
{
userdata.Account = UName;
userdata.IsLoggedIn = true;
userdata.UID = UID;
//以及其他数据初始化
//...
}
/// <summary>
/// 登出
/// </summary>
public void LoginOutData()
{
userdata.IsLoggedIn = false;
//以及其他数据清理
//...
}
/// <summary>
/// 当重连成功
/// </summary>
public void OnReConnected()
{
//如果之前已登录,则重新登录
if (userdata.IsLoggedIn)
{
2024-09-11 18:31:25 +08:00
App.login.Login();
2024-06-28 18:08:25 +08:00
}
}
}
}