Eintoo/GameServer/Server/Hotfix/Outter/Gate/Handler/C2G_LoginRequestHandler.cs

57 lines
2.0 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 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 GateLoginHelper.Login(scene, result.gameAccount, session.RuntimeId);
await FTask.CompletedTask;
}
}