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

47 lines
1.4 KiB
C#
Raw Normal View History

2024-06-28 18:08:25 +08:00
using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.Common;
using AxibugEmuOnline.Client.Network;
using AxibugProtobuf;
using System;
namespace AxibugEmuOnline.Client.Manager
{
public class AppLogin
{
static string LastLoginGuid = "";
public AppLogin()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdLogin, RecvLoginMsg);
}
public void Login()
{
2024-09-11 18:31:25 +08:00
App.log.Debug("-->Login");
2024-08-16 10:20:00 +08:00
if (string.IsNullOrEmpty(LastLoginGuid))
2024-06-28 18:08:25 +08:00
LastLoginGuid = Guid.NewGuid().ToString();
2024-09-11 18:31:25 +08:00
App.user.userdata.Account = LastLoginGuid;
2024-06-28 18:08:25 +08:00
Protobuf_Login msg = new Protobuf_Login()
{
LoginType = 0,
2024-09-11 18:31:25 +08:00
Account = App.user.userdata.Account,
2024-06-28 18:08:25 +08:00
};
App.network.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
2024-06-28 18:08:25 +08:00
}
public void RecvLoginMsg(byte[] reqData)
{
Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Login_RESP>(reqData);
if (msg.Status == LoginResultStatus.Ok)
{
2024-09-11 18:31:25 +08:00
App.log.Info("登录成功");
App.user.InitMainUserData(App.user.userdata.Account, msg.UID);
2024-06-28 18:08:25 +08:00
}
else
{
2024-09-11 18:31:25 +08:00
App.log.Info("登录失败");
2024-06-28 18:08:25 +08:00
}
}
}
}