新增相关协议

This commit is contained in:
2025-08-26 18:03:52 +08:00
parent e0665aae01
commit 7325e268ce
36 changed files with 1402 additions and 1085 deletions

View File

@@ -0,0 +1,66 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network.Interface;
using NB.Chat;
using NB.Game;
namespace NB.Common;
public class G2Common_EnterRequestHandler : RouteRPC<Scene, G2Common_EnterRequest, G2Common_EnterResponse>
{
protected override async FTask Run(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response,
Action reply)
{
response.RouteType = request.RouteType;
switch (scene.SceneType)
{
case SceneType.Game:
{
await RunGame(scene, request, response);
break;
}
case SceneType.Social:
{
await RunSocial(scene, request, response);
break;
}
case SceneType.Map:
{
break;
}
}
await FTask.CompletedTask;
}
private async FTask RunGame(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response)
{
// 在缓存中检查该账号是否存在
var gameAccountManageComponent = scene.GetComponent<PlayerManageComponent>();
var account = await gameAccountManageComponent.Online(scene, request.AccountId, request.GateRouteId);
if (account == null)
{
response.ErrorCode = ErrorCode.ErrServer;
return;
}
response.RoleRouteId = account.RuntimeId;
}
private async FTask RunSocial(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response)
{
// 在缓存中检查该账号是否存在
var chatUnitManageComponent = scene.GetComponent<SocialUnitManageComponent>();
var account = await chatUnitManageComponent.Online(scene, request.AccountId, request.GateRouteId);
if (account == null)
{
response.ErrorCode = ErrorCode.ErrServer;
return;
}
response.RoleRouteId = account.RuntimeId;
}
}