新增相关协议
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB.Game;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
public class G2S_EnterRequestHandler : RouteRPC<Scene, G2S_EnterRequest, S2G_EnterResponse>
|
||||
{
|
||||
protected override async FTask Run(Scene scene, G2S_EnterRequest request, S2G_EnterResponse response,
|
||||
Action reply)
|
||||
{
|
||||
var roleId = request.Role.RoleId;
|
||||
Log.Debug($"收到 G2S_EnterRequestHandler {roleId}");
|
||||
|
||||
// 在缓存中检查该账号是否存在
|
||||
var chatUnitManageComponent = scene.GetComponent<SocialUnitManageComponent>();
|
||||
var account = await chatUnitManageComponent.Online(scene, request.Role, request.GateRouteId);
|
||||
|
||||
response.RoleRouteId = account.RuntimeId;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
public class G2S_ExitRequestHandler : RouteRPC<Scene, G2S_ExitRequest, S2G_ExitResponse>
|
||||
{
|
||||
protected override async FTask Run(Scene scene, G2S_ExitRequest request, S2G_ExitResponse response,
|
||||
Action reply)
|
||||
{
|
||||
// 在缓存中检查该账号是否存在
|
||||
var chatUnitManageComponent = scene.GetComponent<SocialUnitManageComponent>();
|
||||
await chatUnitManageComponent.Offline(scene, request.AccountId, request.GateRouteId);
|
||||
}
|
||||
}
|
||||
@@ -122,52 +122,51 @@ public static class SocialSceneHelper
|
||||
|
||||
#region 上线下线
|
||||
|
||||
public static async FTask<(long, long)> Online(Scene scene, RoleSimpleInfo roleSimple, long gateRuntimeId)
|
||||
{
|
||||
var gameSceneConfig = GetSceneConfig();
|
||||
var gameRouteId = gameSceneConfig.RouteId;
|
||||
//连接到游戏中心服
|
||||
var gameResponse = (S2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
|
||||
gameRouteId, new G2S_EnterRequest()
|
||||
{
|
||||
Role = roleSimple,
|
||||
GateRouteId = gateRuntimeId
|
||||
});
|
||||
|
||||
if (gameResponse.ErrorCode != 0)
|
||||
{
|
||||
return (0, 0);
|
||||
}
|
||||
|
||||
return (gameResponse.RoleRouteId, gameRouteId);
|
||||
// return gameRouteId;
|
||||
}
|
||||
|
||||
public static async FTask Offline(Scene scene, long accountId, long gateRuntimeId, long sceneRouteId)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var gameResponse = (S2G_ExitResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
|
||||
sceneRouteId, new G2S_ExitRequest()
|
||||
{
|
||||
AccountId = accountId,
|
||||
GateRouteId = gateRuntimeId
|
||||
});
|
||||
if (gameResponse.ErrorCode == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Log.Error("重试多次还是退出失败,需检查");
|
||||
}
|
||||
|
||||
private static SceneConfig GetSceneConfig()
|
||||
{
|
||||
var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Social);
|
||||
|
||||
return gameSceneConfigs.First();
|
||||
}
|
||||
// public static async FTask<(long, long)> Online(Scene scene, RoleSimpleInfo roleSimple, long gateRuntimeId)
|
||||
// {
|
||||
// var gameSceneConfig = GetSceneConfig();
|
||||
// var gameRouteId = gameSceneConfig.RouteId;
|
||||
// //连接到游戏中心服
|
||||
// var gameResponse = (S2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
|
||||
// gameRouteId, new G2S_EnterRequest()
|
||||
// {
|
||||
// Role = roleSimple,
|
||||
// GateRouteId = gateRuntimeId
|
||||
// });
|
||||
//
|
||||
// if (gameResponse.ErrorCode != 0)
|
||||
// {
|
||||
// return (0, 0);
|
||||
// }
|
||||
//
|
||||
// return (gameResponse.RoleRouteId, gameRouteId);
|
||||
// }
|
||||
//
|
||||
// public static async FTask Offline(Scene scene, long accountId, long gateRuntimeId, long sceneRouteId)
|
||||
// {
|
||||
// for (int i = 0; i < 10; i++)
|
||||
// {
|
||||
// var gameResponse = (S2G_ExitResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
|
||||
// sceneRouteId, new G2S_ExitRequest()
|
||||
// {
|
||||
// AccountId = accountId,
|
||||
// GateRouteId = gateRuntimeId
|
||||
// });
|
||||
// if (gameResponse.ErrorCode == 0)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Log.Error("重试多次还是退出失败,需检查");
|
||||
// }
|
||||
//
|
||||
// private static SceneConfig GetSceneConfig()
|
||||
// {
|
||||
// var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Social);
|
||||
//
|
||||
// return gameSceneConfigs.First();
|
||||
// }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -29,13 +29,13 @@ public static class ChatUnitManageComponentSystem
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="roleSimpleInfo"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <param name="gateRouteId"></param>
|
||||
public static async FTask<SocialUnit?> Online(this SocialUnitManageComponent self, Scene scene,
|
||||
RoleSimpleInfo roleSimpleInfo,
|
||||
long accountId,
|
||||
long gateRouteId)
|
||||
{
|
||||
var accountId = roleSimpleInfo.RoleId;
|
||||
// var accountId = roleSimpleInfo.RoleId;
|
||||
if (!self.TryGet(accountId, out var account))
|
||||
{
|
||||
account = ChatUnitFactory.Create(scene, accountId);
|
||||
@@ -46,7 +46,7 @@ public static class ChatUnitManageComponentSystem
|
||||
{
|
||||
await account.TryComponent<MailComponent>();
|
||||
account.GateRouteId = gateRouteId;
|
||||
account.Role = roleSimpleInfo;
|
||||
// account.Role = roleSimpleInfo;
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
|
||||
Reference in New Issue
Block a user