新增相关协议
This commit is contained in:
@@ -5,6 +5,8 @@ using Fantasy.Platform.Net;
|
||||
using NB.Chat;
|
||||
using NB.Game;
|
||||
|
||||
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
|
||||
namespace NB.Gate;
|
||||
|
||||
public static class GateLoginHelper
|
||||
@@ -37,43 +39,13 @@ public static class GateLoginHelper
|
||||
var routeComponent = session.GetComponent<RouteComponent>();
|
||||
if (routeComponent == null)
|
||||
{
|
||||
routeComponent = session.AddComponent<RouteComponent>();
|
||||
session.AddComponent<RouteComponent>();
|
||||
}
|
||||
|
||||
gateUnitSessionComponent.AccountID = gateUnit.AccountID;
|
||||
gateUnitSessionComponent.SessionId = session.RuntimeId;
|
||||
|
||||
|
||||
//安排游戏服务器,并通知进入
|
||||
var (gameRouteId, roleSimpleInfo) =
|
||||
await GameSceneHelper.Online(session.Scene, gateUnit.AccountID, session.RuntimeId);
|
||||
if (gameRouteId <= 0 || roleSimpleInfo == null)
|
||||
{
|
||||
return ErrorCode.OnlineSceneFailed;
|
||||
}
|
||||
|
||||
Log.Info($"连接游戏服成功,gameRouteId:{gameRouteId}");
|
||||
routeComponent.AddAddress(RouteType.GameRoute, gameRouteId);
|
||||
gateUnit.GameSceneRouteId = gameRouteId;
|
||||
|
||||
|
||||
//安排进入的聊天服
|
||||
var (chatRouteId, sceneRouteId) =
|
||||
await SocialSceneHelper.Online(session.Scene, roleSimpleInfo, session.RuntimeId);
|
||||
if (chatRouteId <= 0)
|
||||
{
|
||||
return ErrorCode.OnlineSceneFailed;
|
||||
}
|
||||
|
||||
routeComponent.AddAddress(RouteType.SocialRoute, chatRouteId);
|
||||
gateUnit.ChatSceneRouteId = sceneRouteId;
|
||||
Log.Info($"连接聊天服成功,gameRouteId:{gameRouteId}");
|
||||
|
||||
var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Map);
|
||||
|
||||
var mapSceneConfig = gameSceneConfigs.First();
|
||||
routeComponent.AddAddress(RouteType.MapRoute, mapSceneConfig.RouteId);
|
||||
return ErrorCode.Successful;
|
||||
return await gateUnit.Online(RouteType.GameRoute, RouteType.SocialRoute, RouteType.MapRoute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -88,11 +60,13 @@ public static class GateLoginHelper
|
||||
public static async FTask<uint> Offline(GateUnit gateUnit, long sessionId)
|
||||
{
|
||||
//通知服务器下线
|
||||
Log.Info($"断线的session id={sessionId} ChatSceneRouteId={gateUnit.ChatSceneRouteId}");
|
||||
await GameSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId);
|
||||
await SocialSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId,
|
||||
gateUnit.ChatSceneRouteId);
|
||||
return ErrorCode.Successful;
|
||||
Log.Info($"断线的session id={sessionId}");
|
||||
var ret = await gateUnit.Offline(sessionId, RouteType.GameRoute, RouteType.SocialRoute, RouteType.MapRoute);
|
||||
|
||||
// await GameSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId);
|
||||
// await SocialSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId,
|
||||
// gateUnit.ChatSceneRouteId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user