水电费

This commit is contained in:
bob
2025-07-16 17:47:53 +08:00
parent 7cccd2a81c
commit 3bd1ffbb75
75 changed files with 2148 additions and 1265 deletions

View File

@@ -0,0 +1,38 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Authentication.Jwt;
using Fantasy.Network;
using Fantasy.Network.Interface;
using Fantasy.Platform.Net;
namespace Fantasy.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)
{
var scene = session.Scene;
var result = await AuthenticationHelper.Login(scene, request.Username, request.Password);
if (result.ErrorCode == 0)
{
// 通过配置表或其他方式拿到Gate服务器组的信息
var gates = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate);
// 通过当前账号的ID拿到要分配Gate服务器
var gatePosition = result.AccountId % gates.Count;
// 通过计算出来的位置下标拿到Gate服务器的配置
var gateSceneConfig = gates[(int)gatePosition];
// 通过Gate的SceneConfig文件拿到外网的ID地址和端口
var outerPort = gateSceneConfig.OuterPort;
var processConfig = ProcessConfigData.Instance.Get(gateSceneConfig.ProcessConfigId);
var machineConfig = MachineConfigData.Instance.Get(processConfig.MachineId);
// 颁发一个ToKen令牌给客户端
response.ToKen = AuthenticationJwtHelper.GetToken(scene, result.AccountId,
$"{machineConfig.OuterIP}:{outerPort}", gateSceneConfig.Id);
}
response.ErrorCode = result.ErrorCode;
Log.Debug($"Login 当前的服务器是:{scene.SceneConfigId}");
}
}