新增相关协议
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using NB.Common;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
@@ -13,7 +14,7 @@ public static class CacheHandler
|
||||
/// <returns></returns>
|
||||
public static async FTask<List<RoleSimpleInfo>> GetPlayerBasicCacheInfos(Scene scene, List<long> id)
|
||||
{
|
||||
var gameSceneConfig = GameSceneHelper.GetSceneConfig();
|
||||
var gameSceneConfig = SceneConfigHelper.GetConfig(SceneType.Game);
|
||||
var gameRouteId = gameSceneConfig.RouteId;
|
||||
//连接到游戏中心服
|
||||
var gameResponse = (G2S_GetPlayerBasicInfoResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Helper;
|
||||
using Fantasy.Network;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB;
|
||||
using NB.Gate;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
public class G2Game_EnterRequestHandler : RouteRPC<Scene, G2Game_EnterRequest, Game2G_EnterResponse>
|
||||
{
|
||||
protected override async FTask Run(Scene scene, G2Game_EnterRequest request, Game2G_EnterResponse response,
|
||||
Action reply)
|
||||
{
|
||||
Log.Debug("收到 G2Game_EnterRequestHandler");
|
||||
|
||||
|
||||
// 在缓存中检查该账号是否存在
|
||||
var gameAccountManageComponent = scene.GetComponent<PlayerManageComponent>();
|
||||
|
||||
var account = await gameAccountManageComponent.Online(scene, request.AccountId, request.GateRouteId);
|
||||
|
||||
response.RoleRouteId = account.RuntimeId;
|
||||
response.RoleInfo = account.GetRoleSimpleInfo();
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
// using Fantasy;
|
||||
// using Fantasy.Async;
|
||||
// using Fantasy.Entitas;
|
||||
// using Fantasy.Helper;
|
||||
// using Fantasy.Network;
|
||||
// using Fantasy.Network.Interface;
|
||||
// using NB;
|
||||
// using NB.Gate;
|
||||
//
|
||||
// namespace NB.Game;
|
||||
//
|
||||
// public class G2Game_EnterRequestHandler : RouteRPC<Scene, G2Game_EnterRequest, Game2G_EnterResponse>
|
||||
// {
|
||||
// protected override async FTask Run(Scene scene, G2Game_EnterRequest request, Game2G_EnterResponse response,
|
||||
// Action reply)
|
||||
// {
|
||||
// Log.Debug("收到 G2Game_EnterRequestHandler");
|
||||
//
|
||||
//
|
||||
// // 在缓存中检查该账号是否存在
|
||||
// var gameAccountManageComponent = scene.GetComponent<PlayerManageComponent>();
|
||||
//
|
||||
// var account = await gameAccountManageComponent.Online(scene, request.AccountId, request.GateRouteId);
|
||||
//
|
||||
// response.RoleRouteId = account.RuntimeId;
|
||||
// response.RoleInfo = account.GetRoleSimpleInfo();
|
||||
// await FTask.CompletedTask;
|
||||
// }
|
||||
// }
|
||||
@@ -1,48 +0,0 @@
|
||||
using System.Net;
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network;
|
||||
using Fantasy.Platform.Net;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
public static class GameSceneHelper
|
||||
{
|
||||
#region 上线 下线
|
||||
|
||||
public static SceneConfig GetSceneConfig()
|
||||
{
|
||||
var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Game);
|
||||
|
||||
return gameSceneConfigs.First();
|
||||
}
|
||||
|
||||
|
||||
public static async FTask<(long, RoleSimpleInfo?)> Online(Scene scene, long accountID, long gateRuntimeId)
|
||||
{
|
||||
var gameSceneConfig = GetSceneConfig();
|
||||
var gameRouteId = gameSceneConfig.RouteId;
|
||||
//连接到游戏中心服
|
||||
var gameResponse = (Game2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
|
||||
gameRouteId, new G2Game_EnterRequest()
|
||||
{
|
||||
AccountId = accountID,
|
||||
GateRouteId = gateRuntimeId
|
||||
});
|
||||
|
||||
if (gameResponse.ErrorCode != 0)
|
||||
{
|
||||
return (0, null);
|
||||
}
|
||||
|
||||
return (gameResponse.RoleRouteId, gameResponse.RoleInfo);
|
||||
}
|
||||
|
||||
public static async FTask Offline(Scene scene, long accountId, long gateRuntimeId)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
@@ -42,7 +42,8 @@ public static class PlayerManageComponentSystem
|
||||
/// <param name="self"></param>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="accountId"></param>
|
||||
public static async FTask<Player> Online(this PlayerManageComponent self, Scene scene, long accountId,
|
||||
/// <param name="gateRouteId"></param>
|
||||
public static async FTask<Player?> Online(this PlayerManageComponent self, Scene scene, long accountId,
|
||||
long gateRouteId)
|
||||
{
|
||||
Log.Debug("检查账号是否在缓存中");
|
||||
|
||||
@@ -61,7 +61,7 @@ public static class PlayerHelper
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="accountId">账号Id</param>
|
||||
/// <returns></returns>
|
||||
public static async FTask<Player> LoadDataBase(Scene scene, long accountId)
|
||||
public static async FTask<Player?> LoadDataBase(Scene scene, long accountId)
|
||||
{
|
||||
var account = await scene.World.DataBase.First<Player>(d => d.Id == accountId);
|
||||
if (account == null)
|
||||
|
||||
Reference in New Issue
Block a user