Files
FantasyNetTest/FantasyNetTest/LoginTask.cs
2025-08-11 16:09:33 +08:00

45 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using NBC;
using NBC.Network;
namespace FantasyNetTest;
public class LoginTask
{
public static async Task Login(Session session, string account, int type)
{
// // 发送登录的请求给服务器
// var response = (A2C_LoginResponse)await session.Call(new C2A_LoginRequest()
// {
// Username = account,
// Password = account,
// LoginType = type
// });
//
// if (response.ErrorCode != 0)
// {
// Log.Error($"登录发生错误{response.ErrorCode}");
// return;
// }
//
// if (!session.Scene.GetComponent<JWTParseComponent>().Parse(response.ToKen, out var payload))
// {
// return;
// }
//
// // 根据ToKen返回的Address登录到Gate服务器
// session = SessionHelper.CreateSession(session.Scene, payload.Address, OnConnectComplete, OnConnectFail,
// OnConnectDisconnect);
// // 发送登录请求到Gate服务器
// var loginResponse = (G2C_LoginResponse)await session.Call(new C2G_LoginRequest()
// {
// ToKen = response.ToKen
// });
// if (loginResponse.ErrorCode != 0)
// {
// Log.Error($"登录发生错误{loginResponse.ErrorCode}");
// return;
// }
//
// Log.Succeed($"登录到Gate服务器成功ErrorCode:{loginResponse.ErrorCode}");
}
}