对对对
This commit is contained in:
@@ -1,21 +1,46 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Authentication.Jwt;
|
||||
using Fantasy.Network;
|
||||
using Fantasy.Network.Interface;
|
||||
using Fantasy.Platform.Net;
|
||||
using NB.Authentication.Jwt;
|
||||
|
||||
namespace Fantasy.Authentication.Handler;
|
||||
namespace NB.Authentication.Handler;
|
||||
|
||||
public class C2A_LoginRequestHandler : MessageRPC<C2A_LoginRequest, A2C_LoginResponse>
|
||||
{
|
||||
protected override async FTask Run(Session session, C2A_LoginRequest request, A2C_LoginResponse response,
|
||||
Action reply)
|
||||
{
|
||||
if (!session.CheckInterval(2000))
|
||||
{
|
||||
// 返回这个3代表操作过于频繁。
|
||||
response.ErrorCode = ErrorCode.ErrFrequent;
|
||||
return;
|
||||
}
|
||||
|
||||
session.SetTimeout(3000);
|
||||
var scene = session.Scene;
|
||||
var result = await AuthenticationHelper.Login(scene, request.Username, request.Password);
|
||||
|
||||
if (result.ErrorCode == 0)
|
||||
if (result.ErrorCode != ErrorCode.Successful && result.AccountId == -1)
|
||||
{
|
||||
//开始注册账号
|
||||
var regErrorCode =
|
||||
await AuthenticationHelper.Register(session.Scene, request.Username, request.Password, "用户注册");
|
||||
if (regErrorCode != ErrorCode.Successful)
|
||||
{
|
||||
result.ErrorCode = regErrorCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Debug($"Register 当前的服务器是:{scene.SceneConfigId}");
|
||||
//注册完毕,执行登录
|
||||
result = await AuthenticationHelper.Login(scene, request.Username, request.Password);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.ErrorCode == ErrorCode.Successful)
|
||||
{
|
||||
// 通过配置表或其他方式拿到Gate服务器组的信息
|
||||
var gates = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate);
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace Fantasy.Authentication.Handler;
|
||||
|
||||
public sealed class C2A_RegisterRequestHandler : MessageRPC<C2A_RegisterRequest, A2C_RegisterResponse>
|
||||
{
|
||||
protected override async FTask Run(Session session, C2A_RegisterRequest request, A2C_RegisterResponse response,
|
||||
Action reply)
|
||||
{
|
||||
if (!session.CheckInterval(2000))
|
||||
{
|
||||
// 返回这个3代表操作过于频繁。
|
||||
response.ErrorCode = 3;
|
||||
return;
|
||||
}
|
||||
|
||||
session.SetTimeout(3000);
|
||||
response.ErrorCode =
|
||||
await AuthenticationHelper.Register(session.Scene, request.Username, request.Password, "用户注册");
|
||||
Log.Debug($"Register 当前的服务器是:{session.Scene.SceneConfigId}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user