56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using Fantasy.Async;
|
||
using Fantasy.Network;
|
||
using Fantasy.Network.Interface;
|
||
using Hotfix;
|
||
|
||
namespace Fantasy;
|
||
|
||
public class C2G_LoginRequestHandler : MessageRPC<C2G_LoginRequest, G2C_LoginResponse>
|
||
{
|
||
protected override async FTask Run(Session session, C2G_LoginRequest request, G2C_LoginResponse response, Action reply)
|
||
{
|
||
var token = request.Token;
|
||
var scene = session.Scene;
|
||
if (string.IsNullOrEmpty(token))
|
||
{
|
||
Log.Debug("令牌为空,恶意攻击");
|
||
session.Dispose();
|
||
response.ErrorCode = GameErrorCode.GateTokenValidFailed;
|
||
return;
|
||
}
|
||
|
||
if (!GateJwtComponentHelper.ValidateToken(scene,token,out var accountId) )
|
||
{
|
||
Log.Debug("Token校验失败,恶意攻击");
|
||
response.ErrorCode = GameErrorCode.GateTokenValidFailed;
|
||
session.Dispose();
|
||
return;
|
||
}
|
||
|
||
response.ErrorCode = GameErrorCode.GateTokenValidSuccess;
|
||
Log.Debug($"Gate校验登录成功用户{accountId}");
|
||
|
||
var result = await GateComponentHelper.LoginAccountGame(session,accountId);
|
||
|
||
if (result.error == GameErrorCode.GateRepeatedLogin)
|
||
{
|
||
response.ErrorCode = GameErrorCode.GateRepeatedLogin;
|
||
return;
|
||
}
|
||
|
||
response.GameAccount = result.gameAccount.GetGameAccountInfo();
|
||
|
||
Log.Debug($"Gate : Login 登录成功GameAccount:session{session.RuntimeId} AccountId:{accountId} ");
|
||
// var result = GateJwtComponentHelper.ValidateToken(scene, token);
|
||
// response.ErrorCode = result;
|
||
// if (result != GameErrorCode.GateTokenValidSuccess) return;
|
||
// Log.Debug("Gate校验登录令牌成功");
|
||
if (string.IsNullOrEmpty(result.gameAccount.GameName) || result.gameAccount.GameName.Length == 0)
|
||
{
|
||
session.Send(new G2C_OpenGameNameInputWindowsMessage());
|
||
}
|
||
|
||
|
||
await FTask.CompletedTask;
|
||
}
|
||
} |