This commit is contained in:
CortexCore
2024-11-23 17:20:13 +08:00
commit bb257507bc
133 changed files with 2574 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
{
"name": "Com.Project.B.Authorize",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 213fef69b5745f547bdcc386328dc311
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System;
namespace Com.Project.B.Authorize
{
/// <summary>
/// 授权数据
/// </summary>
public interface IAuthorizeData
{
/// <summary>
/// 链接ID,仅用于网络通讯
/// </summary>
int ConnectionId { get; set; }
/// <summary>
/// 玩家ID
/// </summary>
Guid PlayerId { get; }
/// <summary>
/// 授权令牌
/// </summary>
string Token { get; }
/// <summary>
/// 上次更新时间
/// </summary>
DateTime LastUpdateTime { get; }
}
public struct AuthorizeData:IAuthorizeData
{
public int ConnectionId { get; set; }
public Guid PlayerId { get; set; }
public string Token { get; set; }
public DateTime LastUpdateTime { get; set; }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 64fdf8c4f6b4457c87647acd79359508
timeCreated: 1724414639

View File

@@ -0,0 +1,43 @@
using System;
using Com.Project.B.Authorize;
using Cysharp.Threading.Tasks;
namespace Project.B.Authorize
{
/// <summary>
/// 授权服务
/// </summary>
public interface IAuthorizeService
{
/// <summary>
/// 尝试获取授权数据
/// </summary>
/// <param name="playerId"></param>
/// <param name="data"></param>
/// <returns></returns>
bool TryGetAuthorizeData(Guid playerId, out IAuthorizeData data);
UniTask<IAuthorizeData[]> GetAllAuthorizeDataAsync();
/// <summary>
/// 授权和登录
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
UniTask<IAuthorizeData> AuthorizeAsync(IAuthorizeData data);
/// <summary>
/// 保持心跳,超时则断开链接
/// </summary>
/// <param name="playerId"></param>
/// <param name="connectionId"></param>
/// <returns></returns>
UniTask<bool> HeartbeatAsync(Guid playerId,int connectionId);
/// <summary>
/// 授权成功回调
/// </summary>
event Action<IAuthorizeData> OnAuthorized;
/// <summary>
/// 授权超时回调
/// </summary>
event Action<IAuthorizeData> OnAuthorizeTimeout;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d55accd2aeb80c940a0b80fcd1e4c634
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: