39 lines
1.5 KiB
C#

using Fantasy;
using Fantasy.Async;
using Fantasy.Network;
using Fantasy.Platform.Net;
namespace Hotfix;
public static class GateLoginHelper
{
private static List<Func<Scene, GameAccount, long, FTask<(uint error, long chatUnitId,int routeType)>>> scenes =
new List<Func<Scene, GameAccount, long, FTask<(uint error, long chatUnitId,int routeType)>>>()
{
OnlineChat
};
public static async FTask Online(Session session, GameAccount account,long gateRouted)
{
foreach (var scene in scenes)
{
var result = await scene(session.Scene, account, gateRouted);
if (result.error != GameErrorCode.Success) return;
var routeComponent = session.GetOrAddComponent<RouteComponent>();
routeComponent.AddAddress(result.routeType,result.chatUnitId);
}
//await OnlineChat(session.Scene, account, gateRouted);
}
public static async FTask<(uint error,long chatUnitId,int routeType)> OnlineChat(Scene scene, GameAccount account,long gateRouteId)
{
var chat = SceneConfigData.Instance.GetSceneBySceneType(scene.World.Id, SceneType.Chat)[0];
var response = (Chat2G_LoginResponse)await scene.NetworkMessagingComponent.CallInnerRoute(chat.RouteId, new G2Chat_LoginRequest()
{
GameName = account.GameName,
AccountId = account.Id,
GateRoutedId = gateRouteId,
});
return (response.ErrorCode, response.ChatUnitRunId,RouteType.ChatRoute);
}
}