You've already forked CC-Framework.BriskGameServer
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a4f2f6652 | |||
| 4fd2222d6d | |||
| 0e5cab4f27 | |||
| a257a8a912 |
@@ -249,8 +249,10 @@ internal static class BriskModelMapper
|
||||
ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"),
|
||||
ContentChecksum = BriskValueReader.GetString(data, "content_checksum"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
VisitCount = BriskValueReader.GetLong(data, "visit_count"),
|
||||
LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"),
|
||||
UpdatedAt = BriskValueReader.GetString(data, "updated_at")
|
||||
};
|
||||
}
|
||||
@@ -276,7 +278,9 @@ internal static class BriskModelMapper
|
||||
ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"),
|
||||
ContentChecksum = BriskValueReader.GetString(data, "content_checksum"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
VisitCount = BriskValueReader.GetLong(data, "visit_count"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"),
|
||||
UpdatedAt = BriskValueReader.GetString(data, "updated_at")
|
||||
};
|
||||
}
|
||||
@@ -309,7 +313,11 @@ internal static class BriskModelMapper
|
||||
return new BriskSpaceLikeResult
|
||||
{
|
||||
Liked = BriskValueReader.GetBool(data, "liked"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count")
|
||||
Created = BriskValueReader.GetBool(data, "created"),
|
||||
LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
public sealed class BriskSpaceLikeResult
|
||||
{
|
||||
public bool Liked;
|
||||
public bool Created;
|
||||
public bool LikedByMe;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public string LikeResetAt;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ public sealed class BriskSpaceStats
|
||||
public long ContentSizeBytes;
|
||||
public string ContentChecksum;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public long VisitCount;
|
||||
public string LikeResetAt;
|
||||
public string UpdatedAt;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ public sealed class BriskSpaceView
|
||||
public long ContentSizeBytes;
|
||||
public string ContentChecksum;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public long VisitCount;
|
||||
public bool LikedByMe;
|
||||
public string LikeResetAt;
|
||||
public string UpdatedAt;
|
||||
}
|
||||
|
||||
@@ -68,23 +68,23 @@ public sealed class BriskSpaceModule
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按玩家 ID 获取最近点赞列表。
|
||||
/// 按玩家 ID 获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20, bool currentCycleOnly = false)
|
||||
{
|
||||
ValidatePlayerId(playerId);
|
||||
|
||||
return await ExecuteAsync(async context =>
|
||||
{
|
||||
var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLimitQuery(limit), true);
|
||||
var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLikesQuery(limit, currentCycleOnly), true);
|
||||
return (IReadOnlyList<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按登录身份获取最近点赞列表。
|
||||
/// 按登录身份获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20, bool currentCycleOnly = false)
|
||||
{
|
||||
ValidateLoginIdentity(loginProvider, loginUserId);
|
||||
|
||||
@@ -92,6 +92,10 @@ public sealed class BriskSpaceModule
|
||||
{
|
||||
var query = CreateLoginIdentityQuery(loginProvider, loginUserId);
|
||||
query["limit"] = NormalizeLimit(limit);
|
||||
if (currentCycleOnly)
|
||||
{
|
||||
query["scope"] = "cycle";
|
||||
}
|
||||
var data = await context.HttpClient.GetRawDataAsync("/spaces/by-login/likes", query, true);
|
||||
return (IReadOnlyList<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
@@ -236,7 +240,7 @@ public sealed class BriskSpaceModule
|
||||
/// <summary>
|
||||
/// 获取我的访客列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 50)
|
||||
{
|
||||
return await ExecuteAsync(async context =>
|
||||
{
|
||||
@@ -262,6 +266,17 @@ public sealed class BriskSpaceModule
|
||||
};
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> CreateLikesQuery(int limit, bool currentCycleOnly)
|
||||
{
|
||||
var query = CreateLimitQuery(limit);
|
||||
if (currentCycleOnly)
|
||||
{
|
||||
query["scope"] = "cycle";
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
private static void ValidatePlayerId(string playerId)
|
||||
{
|
||||
RequireNotEmpty(playerId, nameof(playerId));
|
||||
|
||||
@@ -475,14 +475,16 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
DrawValueRow("内容版本", _mySpaceView == null ? "-" : _mySpaceView.ContentVersion.ToString());
|
||||
DrawValueRow("内容类型", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.ContentType));
|
||||
DrawValueRow("内容大小", _mySpaceView == null ? "-" : _mySpaceView.ContentSizeBytes + " bytes");
|
||||
DrawValueRow("点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("累计点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("今日点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.TodayLikeCount.ToString());
|
||||
DrawValueRow("访问数", _mySpaceStats == null ? "-" : _mySpaceStats.VisitCount.ToString());
|
||||
DrawValueRow("今日点赞重置", _mySpaceStats == null ? "-" : FormatLikeResetAt(_mySpaceStats.LikeResetAt));
|
||||
DrawValueRow("更新时间", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.UpdatedAt));
|
||||
GUILayout.Space(8f);
|
||||
GUILayout.Label("最近给我点赞的用户", _sectionTitleStyle);
|
||||
GUILayout.Label("今天给我点赞的用户", _sectionTitleStyle);
|
||||
if (_mySpaceLikes.Count == 0)
|
||||
{
|
||||
GUILayout.Label("暂无点赞记录。", _bodyStyle);
|
||||
GUILayout.Label("当前周期暂无点赞记录。", _bodyStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -509,9 +511,11 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
DrawValueRow("PlayerId", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.PlayerId));
|
||||
DrawValueRow("内容类型", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.ContentType));
|
||||
DrawValueRow("内容大小", _targetSpaceView == null ? "-" : _targetSpaceView.ContentSizeBytes + " bytes");
|
||||
DrawValueRow("点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("累计点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("今日点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.TodayLikeCount.ToString());
|
||||
DrawValueRow("访问数", _targetSpaceStats == null ? "-" : _targetSpaceStats.VisitCount.ToString());
|
||||
DrawValueRow("我的点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "已点赞" : "未点赞");
|
||||
DrawValueRow("今日点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "今日已点赞" : "今日未点赞");
|
||||
DrawValueRow("今日点赞重置", _targetSpaceView == null ? "-" : FormatLikeResetAt(_targetSpaceView.LikeResetAt));
|
||||
GUILayout.Space(8f);
|
||||
GUILayout.Label("空间内容", _sectionTitleStyle);
|
||||
GUILayout.TextArea(_targetSpaceContentText ?? string.Empty, _textAreaStyle, GUILayout.Height(240f));
|
||||
@@ -520,8 +524,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
DrawCard("操作", () =>
|
||||
{
|
||||
DrawInlineButtons(
|
||||
new ButtonSpec("点赞", LikeTargetSpaceAsync, false, true),
|
||||
new ButtonSpec("取消点赞", UnlikeTargetSpaceAsync, false, true));
|
||||
new ButtonSpec("今日点赞", LikeTargetSpaceAsync, false, _targetSpaceView != null && !_targetSpaceView.LikedByMe),
|
||||
new ButtonSpec("撤销今日点赞", UnlikeTargetSpaceAsync, false, _targetSpaceView != null && _targetSpaceView.LikedByMe));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -636,7 +640,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
_mySpaceView = await Brisk.Space.GetByPlayerIdAsync(Brisk.PlayerId);
|
||||
_mySpaceStats = await Brisk.Space.GetStatsByPlayerIdAsync(Brisk.PlayerId);
|
||||
_mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10);
|
||||
_mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10, true);
|
||||
SpacePayloadText = await DownloadSpaceTextAsync(_mySpaceView, () => Brisk.Space.DownloadContentByPlayerIdAsync(Brisk.PlayerId));
|
||||
}
|
||||
|
||||
@@ -673,13 +677,15 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
private async Task LikeTargetSpaceAsync()
|
||||
{
|
||||
await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId);
|
||||
var result = await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId);
|
||||
Log("空间今日点赞结果: created=" + result.Created + ", total=" + result.LikeCount + ", today=" + result.TodayLikeCount);
|
||||
await LoadTargetSpaceAsync();
|
||||
}
|
||||
|
||||
private async Task UnlikeTargetSpaceAsync()
|
||||
{
|
||||
await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId);
|
||||
var result = await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId);
|
||||
Log("空间撤销今日点赞结果: total=" + result.LikeCount + ", today=" + result.TodayLikeCount);
|
||||
await LoadTargetSpaceAsync();
|
||||
}
|
||||
|
||||
@@ -1120,6 +1126,22 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
return string.IsNullOrWhiteSpace(value) ? "-" : value;
|
||||
}
|
||||
|
||||
private static string FormatLikeResetAt(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
|
||||
DateTimeOffset parsed;
|
||||
if (!DateTimeOffset.TryParse(value, out parsed))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return parsed.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
private static async Task<string> DownloadSpaceTextAsync(BriskSpaceView view, Func<Task<BriskSpaceContentDownloadResult>> downloadContent)
|
||||
{
|
||||
if (view == null || !view.ContentExists || downloadContent == null)
|
||||
|
||||
@@ -259,7 +259,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
BaseUrl: https://brisk.lightyears.ltd
|
||||
GameKey: briskh5verify
|
||||
GameKey: game_a1faf5ee93d0
|
||||
ClientVersion: 1.0.0
|
||||
DeviceId: editor-device
|
||||
ValidateSessionOnInitialize: 1
|
||||
@@ -268,7 +268,7 @@ MonoBehaviour:
|
||||
LoginCode:
|
||||
Nickname: "Unity\u793A\u4F8B\u73A9\u5BB6"
|
||||
AvatarUrl:
|
||||
RankKey: h5-verify-rank-20260410034312-5cdd
|
||||
RankKey: rank-20260411062004-2bce
|
||||
SubmitScoreValue: 128
|
||||
LeaderboardLimit: 10
|
||||
AroundMeRange: 5
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 0.4.0
|
||||
|
||||
- Added daily-cycle space like fields and result semantics to the Unity SDK models
|
||||
- Added current-cycle filtering support for space like list APIs
|
||||
- Updated the quick start sample to display total likes, today likes, like reset time, and current-cycle like actions
|
||||
- Changed `GetMyVisitsAsync()` default page size to `50` while preserving the optional `limit` parameter
|
||||
- Refreshed package and integration documentation to match the latest production API behavior
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Renamed the UPM package identifier to `com.foldcc.cc-framework.brisk-game-server`
|
||||
|
||||
@@ -64,6 +64,12 @@ await Brisk.Space.UpdateMyAsync(new
|
||||
var mySpace = await Brisk.Space.GetByPlayerIdAsync(Brisk.PlayerId);
|
||||
var myContent = await Brisk.Space.DownloadContentByPlayerIdAsync(Brisk.PlayerId);
|
||||
var text = Encoding.UTF8.GetString(myContent.Bytes);
|
||||
|
||||
var likeResult = await Brisk.Space.LikeByPlayerIdAsync("target-player-id");
|
||||
Debug.Log($"total={likeResult.LikeCount}, today={likeResult.TodayLikeCount}, created={likeResult.Created}");
|
||||
|
||||
var todayLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 20, true);
|
||||
var visits = await Brisk.Space.GetMyVisitsAsync();
|
||||
```
|
||||
|
||||
Notes:
|
||||
@@ -72,6 +78,11 @@ Notes:
|
||||
- `GetByPlayerIdAsync(...)` returns metadata only
|
||||
- use `DownloadContentByPlayerIdAsync(...)` to read the actual content bytes
|
||||
- `UpdateMyAsync(...)` automatically picks text / binary / json behavior from the payload type
|
||||
- space likes are now tracked by natural day in `Asia/Shanghai`
|
||||
- `BriskSpaceView` / `BriskSpaceStats` include both `LikeCount` and `TodayLikeCount`
|
||||
- `BriskSpaceView` also includes `LikedByMe` and `LikeResetAt`
|
||||
- `GetLikesByPlayerIdAsync(..., currentCycleOnly: true)` returns current-cycle likes only
|
||||
- `GetMyVisitsAsync()` now defaults to the latest `50` visits, with `100` as the server-side max
|
||||
|
||||
## Sample
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Brisk Unity SDK 的 UPM 发布目录。
|
||||
4. 输入:
|
||||
|
||||
```text
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0
|
||||
```
|
||||
|
||||
### 方式二:修改 `Packages/manifest.json`
|
||||
@@ -30,12 +30,12 @@ http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0"
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果需要跟随主分支最新代码,可将末尾的 `#v0.3.0` 改成 `#main`;正式环境建议固定到发布 tag。
|
||||
如果需要跟随主分支最新代码,可将末尾的 `#v0.4.0` 改成 `#main`;正式环境建议固定到发布 tag。
|
||||
|
||||
## 开发态源码位置
|
||||
|
||||
@@ -87,6 +87,9 @@ http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path
|
||||
- `UpdateMyAsync(string)` 直接上传文本
|
||||
- `UpdateMyAsync(byte[])` 直接上传二进制
|
||||
- `UpdateMyAsync(object)` 自动序列化为 JSON
|
||||
- `LikeByPlayerIdAsync(...)` / `UnlikeByPlayerIdAsync(...)` 返回累计点赞数、今日点赞数、当前周期是否创建新点赞、重置时间
|
||||
- `GetLikesByPlayerIdAsync(playerId, limit, true)` 和 `GetLikesByLoginIdentityAsync(..., true)` 可只读取当前周期点赞记录
|
||||
- `GetMyVisitsAsync()` 默认读取最近 `50` 条访问记录,也可手动传入 `limit`
|
||||
|
||||
## 目录结构
|
||||
|
||||
|
||||
@@ -249,8 +249,10 @@ internal static class BriskModelMapper
|
||||
ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"),
|
||||
ContentChecksum = BriskValueReader.GetString(data, "content_checksum"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
VisitCount = BriskValueReader.GetLong(data, "visit_count"),
|
||||
LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"),
|
||||
UpdatedAt = BriskValueReader.GetString(data, "updated_at")
|
||||
};
|
||||
}
|
||||
@@ -276,7 +278,9 @@ internal static class BriskModelMapper
|
||||
ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"),
|
||||
ContentChecksum = BriskValueReader.GetString(data, "content_checksum"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
VisitCount = BriskValueReader.GetLong(data, "visit_count"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"),
|
||||
UpdatedAt = BriskValueReader.GetString(data, "updated_at")
|
||||
};
|
||||
}
|
||||
@@ -309,7 +313,11 @@ internal static class BriskModelMapper
|
||||
return new BriskSpaceLikeResult
|
||||
{
|
||||
Liked = BriskValueReader.GetBool(data, "liked"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count")
|
||||
Created = BriskValueReader.GetBool(data, "created"),
|
||||
LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"),
|
||||
LikeCount = BriskValueReader.GetLong(data, "like_count"),
|
||||
TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"),
|
||||
LikeResetAt = BriskValueReader.GetString(data, "like_reset_at")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
public sealed class BriskSpaceLikeResult
|
||||
{
|
||||
public bool Liked;
|
||||
public bool Created;
|
||||
public bool LikedByMe;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public string LikeResetAt;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ public sealed class BriskSpaceStats
|
||||
public long ContentSizeBytes;
|
||||
public string ContentChecksum;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public long VisitCount;
|
||||
public string LikeResetAt;
|
||||
public string UpdatedAt;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ public sealed class BriskSpaceView
|
||||
public long ContentSizeBytes;
|
||||
public string ContentChecksum;
|
||||
public long LikeCount;
|
||||
public long TodayLikeCount;
|
||||
public long VisitCount;
|
||||
public bool LikedByMe;
|
||||
public string LikeResetAt;
|
||||
public string UpdatedAt;
|
||||
}
|
||||
|
||||
@@ -68,23 +68,23 @@ public sealed class BriskSpaceModule
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按玩家 ID 获取最近点赞列表。
|
||||
/// 按玩家 ID 获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20, bool currentCycleOnly = false)
|
||||
{
|
||||
ValidatePlayerId(playerId);
|
||||
|
||||
return await ExecuteAsync(async context =>
|
||||
{
|
||||
var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLimitQuery(limit), true);
|
||||
var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLikesQuery(limit, currentCycleOnly), true);
|
||||
return (IReadOnlyList<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按登录身份获取最近点赞列表。
|
||||
/// 按登录身份获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20, bool currentCycleOnly = false)
|
||||
{
|
||||
ValidateLoginIdentity(loginProvider, loginUserId);
|
||||
|
||||
@@ -92,6 +92,10 @@ public sealed class BriskSpaceModule
|
||||
{
|
||||
var query = CreateLoginIdentityQuery(loginProvider, loginUserId);
|
||||
query["limit"] = NormalizeLimit(limit);
|
||||
if (currentCycleOnly)
|
||||
{
|
||||
query["scope"] = "cycle";
|
||||
}
|
||||
var data = await context.HttpClient.GetRawDataAsync("/spaces/by-login/likes", query, true);
|
||||
return (IReadOnlyList<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
@@ -236,7 +240,7 @@ public sealed class BriskSpaceModule
|
||||
/// <summary>
|
||||
/// 获取我的访客列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 50)
|
||||
{
|
||||
return await ExecuteAsync(async context =>
|
||||
{
|
||||
@@ -262,6 +266,17 @@ public sealed class BriskSpaceModule
|
||||
};
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> CreateLikesQuery(int limit, bool currentCycleOnly)
|
||||
{
|
||||
var query = CreateLimitQuery(limit);
|
||||
if (currentCycleOnly)
|
||||
{
|
||||
query["scope"] = "cycle";
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
private static void ValidatePlayerId(string playerId)
|
||||
{
|
||||
RequireNotEmpty(playerId, nameof(playerId));
|
||||
|
||||
@@ -475,14 +475,16 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
DrawValueRow("内容版本", _mySpaceView == null ? "-" : _mySpaceView.ContentVersion.ToString());
|
||||
DrawValueRow("内容类型", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.ContentType));
|
||||
DrawValueRow("内容大小", _mySpaceView == null ? "-" : _mySpaceView.ContentSizeBytes + " bytes");
|
||||
DrawValueRow("点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("累计点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("今日点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.TodayLikeCount.ToString());
|
||||
DrawValueRow("访问数", _mySpaceStats == null ? "-" : _mySpaceStats.VisitCount.ToString());
|
||||
DrawValueRow("今日点赞重置", _mySpaceStats == null ? "-" : FormatLikeResetAt(_mySpaceStats.LikeResetAt));
|
||||
DrawValueRow("更新时间", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.UpdatedAt));
|
||||
GUILayout.Space(8f);
|
||||
GUILayout.Label("最近给我点赞的用户", _sectionTitleStyle);
|
||||
GUILayout.Label("今天给我点赞的用户", _sectionTitleStyle);
|
||||
if (_mySpaceLikes.Count == 0)
|
||||
{
|
||||
GUILayout.Label("暂无点赞记录。", _bodyStyle);
|
||||
GUILayout.Label("当前周期暂无点赞记录。", _bodyStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -509,9 +511,11 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
DrawValueRow("PlayerId", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.PlayerId));
|
||||
DrawValueRow("内容类型", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.ContentType));
|
||||
DrawValueRow("内容大小", _targetSpaceView == null ? "-" : _targetSpaceView.ContentSizeBytes + " bytes");
|
||||
DrawValueRow("点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("累计点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString());
|
||||
DrawValueRow("今日点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.TodayLikeCount.ToString());
|
||||
DrawValueRow("访问数", _targetSpaceStats == null ? "-" : _targetSpaceStats.VisitCount.ToString());
|
||||
DrawValueRow("我的点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "已点赞" : "未点赞");
|
||||
DrawValueRow("今日点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "今日已点赞" : "今日未点赞");
|
||||
DrawValueRow("今日点赞重置", _targetSpaceView == null ? "-" : FormatLikeResetAt(_targetSpaceView.LikeResetAt));
|
||||
GUILayout.Space(8f);
|
||||
GUILayout.Label("空间内容", _sectionTitleStyle);
|
||||
GUILayout.TextArea(_targetSpaceContentText ?? string.Empty, _textAreaStyle, GUILayout.Height(240f));
|
||||
@@ -520,8 +524,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
DrawCard("操作", () =>
|
||||
{
|
||||
DrawInlineButtons(
|
||||
new ButtonSpec("点赞", LikeTargetSpaceAsync, false, true),
|
||||
new ButtonSpec("取消点赞", UnlikeTargetSpaceAsync, false, true));
|
||||
new ButtonSpec("今日点赞", LikeTargetSpaceAsync, false, _targetSpaceView != null && !_targetSpaceView.LikedByMe),
|
||||
new ButtonSpec("撤销今日点赞", UnlikeTargetSpaceAsync, false, _targetSpaceView != null && _targetSpaceView.LikedByMe));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -636,7 +640,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
_mySpaceView = await Brisk.Space.GetByPlayerIdAsync(Brisk.PlayerId);
|
||||
_mySpaceStats = await Brisk.Space.GetStatsByPlayerIdAsync(Brisk.PlayerId);
|
||||
_mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10);
|
||||
_mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10, true);
|
||||
SpacePayloadText = await DownloadSpaceTextAsync(_mySpaceView, () => Brisk.Space.DownloadContentByPlayerIdAsync(Brisk.PlayerId));
|
||||
}
|
||||
|
||||
@@ -673,13 +677,15 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
private async Task LikeTargetSpaceAsync()
|
||||
{
|
||||
await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId);
|
||||
var result = await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId);
|
||||
Log("空间今日点赞结果: created=" + result.Created + ", total=" + result.LikeCount + ", today=" + result.TodayLikeCount);
|
||||
await LoadTargetSpaceAsync();
|
||||
}
|
||||
|
||||
private async Task UnlikeTargetSpaceAsync()
|
||||
{
|
||||
await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId);
|
||||
var result = await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId);
|
||||
Log("空间撤销今日点赞结果: total=" + result.LikeCount + ", today=" + result.TodayLikeCount);
|
||||
await LoadTargetSpaceAsync();
|
||||
}
|
||||
|
||||
@@ -1120,6 +1126,22 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
return string.IsNullOrWhiteSpace(value) ? "-" : value;
|
||||
}
|
||||
|
||||
private static string FormatLikeResetAt(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
|
||||
DateTimeOffset parsed;
|
||||
if (!DateTimeOffset.TryParse(value, out parsed))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return parsed.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
private static async Task<string> DownloadSpaceTextAsync(BriskSpaceView view, Func<Task<BriskSpaceContentDownloadResult>> downloadContent)
|
||||
{
|
||||
if (view == null || !view.ContentExists || downloadContent == null)
|
||||
|
||||
@@ -259,7 +259,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
BaseUrl: https://brisk.lightyears.ltd
|
||||
GameKey: briskh5verify
|
||||
GameKey: game_a1faf5ee93d0
|
||||
ClientVersion: 1.0.0
|
||||
DeviceId: editor-device
|
||||
ValidateSessionOnInitialize: 1
|
||||
@@ -268,7 +268,7 @@ MonoBehaviour:
|
||||
LoginCode:
|
||||
Nickname: "Unity\u793A\u4F8B\u73A9\u5BB6"
|
||||
AvatarUrl:
|
||||
RankKey: h5-verify-rank-20260410034312-5cdd
|
||||
RankKey: rank-20260411062004-2bce
|
||||
SubmitScoreValue: 128
|
||||
LeaderboardLimit: 10
|
||||
AroundMeRange: 5
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.foldcc.cc-framework.brisk-game-server",
|
||||
"displayName": "FoldCC Brisk Game Server SDK",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"unity": "2021.3",
|
||||
"description": "A lightweight Unity SDK for Brisk game services, including bootstrap, auth, announcements, leaderboard, archive, and player space modules.",
|
||||
"keywords": [
|
||||
|
||||
10
README.md
10
README.md
@@ -34,6 +34,9 @@ Brisk Unity SDK 原始开发工程。
|
||||
- `Brisk.Space.UpdateMyAsync(byte[])` 可直接更新二进制内容
|
||||
- `Brisk.Space.UpdateMyAsync(object)` 会自动转成 JSON 上传
|
||||
- `Brisk.Space.DownloadContentByPlayerIdAsync(playerId)` 获取原始 bytes
|
||||
- `Brisk.Space.LikeByPlayerIdAsync(playerId)` / `UnlikeByPlayerIdAsync(playerId)` 会返回累计点赞数、今日点赞数、当前周期是否创建了新点赞、重置时间
|
||||
- `Brisk.Space.GetLikesByPlayerIdAsync(playerId, limit, true)` 可只读取当前周期点赞列表
|
||||
- `Brisk.Space.GetMyVisitsAsync()` 默认读取最近 `50` 条访问记录,也可手动传入 `limit`
|
||||
|
||||
云存档上传补充约定:
|
||||
|
||||
@@ -82,6 +85,7 @@ Brisk Unity SDK 原始开发工程。
|
||||
- 排行榜读取、提交分数、赛季查询
|
||||
- 云存档上传下载
|
||||
- 玩家空间读取、点赞、更新、访客
|
||||
- 玩家空间今日点赞数、今日点赞状态、今日点赞重置时间
|
||||
- 全局事件日志与最近一次结果输出
|
||||
|
||||
当前样例已经直接使用 `UploadTextAsync` / `DownloadTextAsync` 这类快捷接口;如果业务需要,也可以继续走原始 bytes 接口。
|
||||
@@ -138,7 +142,7 @@ Brisk Unity SDK 原始开发工程。
|
||||
外部项目 Git Package 接入示例:
|
||||
|
||||
```text
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0
|
||||
```
|
||||
|
||||
## 如何引入到项目
|
||||
@@ -165,12 +169,12 @@ http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0"
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果要跟随主分支最新代码,可把末尾的 `#v0.3.0` 改成 `#main`;正式项目仍建议固定到发布 tag。
|
||||
如果要跟随主分支最新代码,可把末尾的 `#v0.4.0` 改成 `#main`;正式项目仍建议固定到发布 tag。
|
||||
|
||||
## 文档位置
|
||||
|
||||
|
||||
@@ -19,17 +19,41 @@
|
||||
|
||||
## 2. 客户端主流程
|
||||
|
||||
1. `GET /api/client/bootstrap`
|
||||
2. `POST /api/auth/login/exchange`
|
||||
3. 带 `Bearer access_token` 调用:
|
||||
1. 可选:`GET /api/client/time`
|
||||
2. `GET /api/client/bootstrap`
|
||||
3. `POST /api/auth/login/exchange`
|
||||
4. 带 `Bearer access_token` 调用:
|
||||
- `GET /api/player/me`
|
||||
- `GET /api/announcements`
|
||||
- 排行榜、存档、空间等业务接口
|
||||
4. `GET /api/config/current` 为公开接口,登录前后都可调用
|
||||
5. `GET /api/config/current` 为公开接口,登录前后都可调用
|
||||
|
||||
## 3. 初始化
|
||||
|
||||
### 3.1 获取初始化信息
|
||||
### 3.1 获取平台时间
|
||||
|
||||
`GET /api/client/time`
|
||||
|
||||
说明:
|
||||
|
||||
- 平台级匿名授时接口
|
||||
- 不需要 `game_key`
|
||||
- 不依赖任何项目配置
|
||||
- 返回 UTC 时间,适合客户端启动时做统一对时
|
||||
|
||||
示例:
|
||||
|
||||
```bash
|
||||
curl "https://brisk.lightyears.ltd/api/client/time"
|
||||
```
|
||||
|
||||
返回重点:
|
||||
|
||||
- `server_time`
|
||||
- `server_unix`
|
||||
- `server_unix_ms`
|
||||
|
||||
### 3.2 获取初始化信息
|
||||
|
||||
`GET /api/client/bootstrap`
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
## 1. 这份文档适合做什么
|
||||
|
||||
这份文档用于说明当前 Brisk Unity SDK 的接入结构与推荐调用方式。
|
||||
这份文档用于在 Unity 侧封装 Brisk SDK。
|
||||
|
||||
当前 SDK 已采用静态总入口:
|
||||
建议把 SDK 拆成以下层次:
|
||||
|
||||
- `Brisk.InitializeAsync(...)`
|
||||
- `Brisk.Auth.xxx`
|
||||
- `Brisk.Player.xxx`
|
||||
- `Brisk.Config.xxx`
|
||||
- `Brisk.Announcements.xxx`
|
||||
- `Brisk.Leaderboard.xxx`
|
||||
- `Brisk.Archive.xxx`
|
||||
- `Brisk.Space.xxx`
|
||||
- `BriskTime`
|
||||
- `BriskClient`
|
||||
- `BriskAuth`
|
||||
- `BriskConfig`
|
||||
- `BriskAnnouncements`
|
||||
- `BriskRanks`
|
||||
- `BriskArchives`
|
||||
- `BriskSpaces`
|
||||
|
||||
## 2. 初始化模型
|
||||
|
||||
@@ -26,6 +26,8 @@ Unity 客户端初始化建议持有:
|
||||
|
||||
不再需要项目级 `channel / platform`。
|
||||
|
||||
如果只是做平台授时,不需要传 `gameKey`,可以单独调用时间接口。
|
||||
|
||||
示例:
|
||||
|
||||
```csharp
|
||||
@@ -64,18 +66,31 @@ Task<LoginResult> LoginAsync(
|
||||
|
||||
## 4. 推荐接入顺序
|
||||
|
||||
1. `BootstrapAsync()`
|
||||
2. 从第三方 SDK 获取:
|
||||
1. 可选:`SyncServerTimeAsync()`
|
||||
2. `BootstrapAsync()`
|
||||
3. 从第三方 SDK 获取:
|
||||
- `loginProvider`
|
||||
- `loginUserId` 或 `code`
|
||||
- 可选昵称、头像、扩展资料
|
||||
3. `LoginAsync(...)`
|
||||
4. 保存 `accessToken`
|
||||
5. 拉取:
|
||||
4. `LoginAsync(...)`
|
||||
5. 保存 `accessToken`
|
||||
6. 拉取:
|
||||
- `GetMeAsync()`
|
||||
- `GetCurrentConfigAsync()`
|
||||
- `ListAnnouncementsAsync()`
|
||||
6. 进入业务模块
|
||||
7. 进入业务模块
|
||||
|
||||
平台授时接口建议封装:
|
||||
|
||||
```csharp
|
||||
Task<ServerTimeResult> SyncServerTimeAsync()
|
||||
```
|
||||
|
||||
建议返回:
|
||||
|
||||
- `ServerTime`
|
||||
- `ServerUnix`
|
||||
- `ServerUnixMs`
|
||||
|
||||
## 5. 身份模型建议
|
||||
|
||||
@@ -142,27 +157,12 @@ Task LikeSpaceByLoginIdentityAsync(string loginProvider, string loginUserId)
|
||||
- msgpack bytes
|
||||
- 压缩后的存档二进制
|
||||
|
||||
当前 SDK 已提供:
|
||||
Unity SDK 建议提供:
|
||||
|
||||
- `GetArchiveSlotsAsync()`
|
||||
- `GetArchiveMetaAsync(slotNo)`
|
||||
- `UploadAsync(slotNo, byte[], baseVersion, checksum)`
|
||||
- `UploadTextAsync(slotNo, text, baseVersion, checksum)`
|
||||
- `UploadJsonAsync(slotNo, payload, baseVersion, checksum)`
|
||||
- `UploadArchiveAsync(slotNo, baseVersion, checksum, byte[])`
|
||||
- `DownloadArchiveAsync(slotNo)`
|
||||
- `DownloadTextAsync(slotNo)`
|
||||
- `DownloadJsonAsync(slotNo)`
|
||||
|
||||
推荐上层使用策略:
|
||||
|
||||
- 文本存档:优先直接用 `UploadTextAsync / DownloadTextAsync`
|
||||
- JSON 存档:优先直接用 `UploadJsonAsync / DownloadJsonAsync`
|
||||
- 二进制存档:继续用 `UploadAsync / DownloadAsync`
|
||||
|
||||
其中:
|
||||
|
||||
- SDK 会自动计算上传用 `checksum`
|
||||
- 手动传 `checksum` 时也可以带 `sha256:` 前缀,SDK 会自动归一化
|
||||
|
||||
## 9. 玩家空间模块建议
|
||||
|
||||
@@ -177,7 +177,7 @@ Task LikeSpaceByLoginIdentityAsync(string loginProvider, string loginUserId)
|
||||
- 小型二进制空间内容
|
||||
- 文本、JSON、protobuf、msgpack 等自定义格式
|
||||
|
||||
当前 SDK / 接口核心是:
|
||||
当前接口核心是:
|
||||
|
||||
- `UploadMySpaceContentAsync(baseVersion, contentType, checksum, byte[])`
|
||||
- `DownloadSpaceContentByPlayerIdAsync(playerId)`
|
||||
@@ -188,16 +188,6 @@ Task LikeSpaceByLoginIdentityAsync(string loginProvider, string loginUserId)
|
||||
- `LikeSpaceByLoginIdentityAsync(loginProvider, loginUserId)`
|
||||
- `GetMyVisitsAsync(limit)`
|
||||
|
||||
当前 SDK 额外提供了一个极简便捷入口:
|
||||
|
||||
- `Brisk.Space.UpdateMyAsync(payload, baseVersion, contentType, checksum)`
|
||||
|
||||
它的行为是:
|
||||
|
||||
- `payload` 为 `string` 时,自动按 `text/plain` 上传
|
||||
- `payload` 为 `byte[]` 时,自动按 `application/octet-stream` 上传
|
||||
- `payload` 为其他对象时,自动序列化为 JSON 并按 `application/json` 上传
|
||||
|
||||
建议 SDK 暴露两层模型:
|
||||
|
||||
- 空间主信息:
|
||||
@@ -213,8 +203,7 @@ Task LikeSpaceByLoginIdentityAsync(string loginProvider, string loginUserId)
|
||||
- 下载响应头中的 `X-Space-Version`
|
||||
- 下载响应头中的 `X-Space-Checksum`
|
||||
|
||||
如果上层业务追求最省事,可以直接用 `UpdateMyAsync(string)` 或 `UpdateMyAsync(object)`;
|
||||
如果业务自己管理编码、压缩、protobuf、msgpack 等格式,则继续走 `byte[]` 上传下载接口。
|
||||
如果上层业务实际保存的是文本或 JSON,建议仍按 `byte[]` 统一收发,再由业务层自己决定如何编码和反序列化。
|
||||
|
||||
## 10. 动态配置建议
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Brisk 错误码文档(内部实施版)
|
||||
|
||||
**版本**:v0.1
|
||||
**日期**:2026-04-08
|
||||
**版本**:v0.2
|
||||
**日期**:2026-04-11
|
||||
**说明**:当前工程内已使用的错误码分组与含义。
|
||||
|
||||
---
|
||||
@@ -45,6 +45,13 @@
|
||||
|
||||
## 3. 当前已使用错误码
|
||||
|
||||
补充说明:
|
||||
|
||||
- `GET /api/client/time` 为平台匿名授时接口
|
||||
- 该接口当前没有新增专属业务错误码
|
||||
- 触发限流时仍使用通用限流错误码 `80001`
|
||||
- 限流组件不可用时仍使用通用错误码 `80002`
|
||||
|
||||
| 错误码 | 接口/模块 | 含义 |
|
||||
|---|---|---|
|
||||
| `10001` | 客户端鉴权 | 缺少 token |
|
||||
|
||||
@@ -4,6 +4,7 @@ Brisk 游戏服务端工程。
|
||||
|
||||
当前已实现模块:
|
||||
|
||||
- 平台授时 `time`
|
||||
- 客户端初始化 `bootstrap`
|
||||
- 登录换票 `auth`
|
||||
- 玩家信息 `player`
|
||||
@@ -20,6 +21,7 @@ Brisk 游戏服务端工程。
|
||||
- 项目唯一标识只有 `game_key`
|
||||
- 项目级 `channel / platform` 已移除
|
||||
- 初始化和动态配置只依赖 `game_key`,配置筛选只看 `client_version`
|
||||
- 平台授时接口不依赖 `game_key`,可直接匿名获取 UTC 服务器时间
|
||||
- 登录模块单独处理第三方身份:
|
||||
- `login_provider`:如 `tap`
|
||||
- `login_user_id`:该登录平台返回的稳定唯一用户 ID
|
||||
@@ -43,6 +45,7 @@ docker compose up --build
|
||||
|
||||
- `GET /health`
|
||||
- `GET /api/ping`
|
||||
- `GET /api/client/time`
|
||||
- `GET /openapi.yaml`
|
||||
|
||||
开发环境默认账号:
|
||||
@@ -54,6 +57,10 @@ docker compose up --build
|
||||
|
||||
## 接入说明
|
||||
|
||||
- 平台授时:
|
||||
- 匿名接口 `GET /api/client/time`
|
||||
- 无需传 `game_key`
|
||||
- 返回 `server_time`、`server_unix`、`server_unix_ms`
|
||||
- 客户端初始化:
|
||||
- 必填 `game_key`
|
||||
- 可选 `client_version`
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Brisk Game Service API
|
||||
version: 0.1.0
|
||||
version: 0.2.0
|
||||
description: Current implemented Brisk server API for internal integration.
|
||||
servers:
|
||||
- url: /api
|
||||
tags:
|
||||
- name: time
|
||||
- name: bootstrap
|
||||
- name: auth
|
||||
- name: player
|
||||
@@ -51,6 +52,21 @@ components:
|
||||
type: string
|
||||
data:
|
||||
nullable: true
|
||||
ClientTimePayload:
|
||||
type: object
|
||||
properties:
|
||||
server_time:
|
||||
type: string
|
||||
format: date-time
|
||||
example: 2026-04-11T08:12:30Z
|
||||
server_unix:
|
||||
type: integer
|
||||
format: int64
|
||||
example: 1775895150
|
||||
server_unix_ms:
|
||||
type: integer
|
||||
format: int64
|
||||
example: 1775895150123
|
||||
ExchangeRequest:
|
||||
type: object
|
||||
required: [game_key, login_provider]
|
||||
@@ -494,6 +510,28 @@ components:
|
||||
type: string
|
||||
format: date-time
|
||||
paths:
|
||||
/client/time:
|
||||
get:
|
||||
tags: [time]
|
||||
summary: Get platform server time
|
||||
responses:
|
||||
'200':
|
||||
description: Current platform UTC time
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
example: 0
|
||||
message:
|
||||
type: string
|
||||
example: ok
|
||||
data:
|
||||
$ref: '#/components/schemas/ClientTimePayload'
|
||||
'429': { description: Rate limited }
|
||||
'500': { description: Rate limit unavailable }
|
||||
/client/bootstrap:
|
||||
get:
|
||||
tags: [bootstrap]
|
||||
|
||||
Reference in New Issue
Block a user