修改协议工具

This commit is contained in:
2025-07-27 23:46:43 +08:00
parent 743c1d2baa
commit be33e12b35
112 changed files with 1021 additions and 1119 deletions

View File

@@ -0,0 +1,66 @@
using Fantasy;
using Fantasy.Async;
namespace NB.Authentication;
public static class AuthenticationHelper
{
/// <summary>
/// 登录账号
/// </summary>
/// <param name="scene"></param>
/// <param name="userName">用户名</param>
/// <param name="password">用户密码</param>
/// <returns></returns>
public static async FTask<(uint ErrorCode, long AccountId)> Login(Scene scene, string userName, string password)
{
return await scene.GetComponent<AuthenticationComponent>().Login(userName, password);
}
/// <summary>
/// 注册一个新的账号
/// </summary>
/// <param name="scene"></param>
/// <param name="username">用户名</param>
/// <param name="password">用户密码</param>
/// <param name="source">注册的来源/原因</param>
/// <returns></returns>
public static async FTask<uint> Register(Scene scene, string username, string password, string source)
{
return await scene.GetComponent<AuthenticationComponent>().Register(username, password, source);
}
/// <summary>
/// 移除一个账号
/// </summary>
/// <param name="scene"></param>
/// <param name="accountId">账号ID</param>
/// <param name="source">移除的来源/原因</param>
/// <returns></returns>
public static async FTask<uint> Remove(Scene scene, long accountId, string source)
{
return await scene.GetComponent<AuthenticationComponent>().Remove(accountId, source);
}
/// <summary>
/// 移除缓存中的Account
/// </summary>
/// <param name="scene"></param>
/// <param name="username">账号名字</param>
/// <param name="isDispose">是否销毁</param>
public static void RemoveCache(Scene scene, string username, bool isDispose)
{
scene.GetComponent<AuthenticationComponent>().RemoveCache(username, isDispose);
}
/// <summary>
/// 移除LoginAccounts缓存中的数据仅供内部调用不明白原理的不要调用否则后果自负。
/// </summary>
/// <param name="scene"></param>
/// <param name="key"></param>
/// <param name="isDispose"></param>
internal static void RemoveLoginAccounts(Scene scene, string key, bool isDispose)
{
scene.GetComponent<AuthenticationComponent>().RemoveLoginAccounts(key, isDispose);
}
}