NoSugarNet/NoSugarNet.ClientCore/Manager/AppLogin.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2024-01-19 21:35:05 +08:00
using AxibugProtobuf;
using NoSugarNet.ClientCore.Common;
using NoSugarNet.ClientCore.Network;
namespace NoSugarNet.ClientCore.Manager
{
public class AppLogin
{
public AppLogin()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdLogin, RecvLoginMsg);
}
public void Login(string Account)
{
Protobuf_Login msg = new Protobuf_Login()
{
LoginType = 0,
Account = Account,
};
2024-01-22 11:56:02 +08:00
AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
2024-01-19 21:35:05 +08:00
}
public void RecvLoginMsg(byte[] reqData)
{
Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Login_RESP>(reqData);
if (msg.Status == LoginResultStatus.Ok)
{
2024-04-15 15:16:10 +08:00
AppNoSugarNet.log.Info("登录成功");
2024-01-22 11:56:02 +08:00
AppNoSugarNet.user.InitMainUserData(AppNoSugarNet.user.userdata.Account);
2024-01-19 21:35:05 +08:00
}
else
{
2024-04-15 15:16:10 +08:00
AppNoSugarNet.log.Info("登录失败");
2024-01-19 21:35:05 +08:00
}
}
}
}