Skip to content

Commit

Permalink
add applicationVersionId
Browse files Browse the repository at this point in the history
  • Loading branch information
transcai committed Oct 13, 2023
1 parent 1e1f8d5 commit b47b73c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ curl -X POST --data "ClientSession=xxx&RequestId=req123&UserId=userid123&Project

- 请求

| 字段 | 类型 | 必要 | 描述 |
| ------------- | ------ | -------------- | ------------------------------------------------------------------------------------------------------------------- |
| UserId | string || 用户 ID,业务自定义生成,不同用户需要生成不同 UserId 来区分 |
| ProjectId | string || 项目 ID,应用云渲染项目创建时生成,[项目管理](https://console.cloud.tencent.com/car/project) 中获取,格式为 cap-xxx |
| ApplicationId | string || 应用 ID,多应用共享项目请求时有效,应用云渲染应用创建时生成,[应用管理](https://console.cloud.tencent.com/car/application) 中获取,格式为 app-xxx |
| ClientSession | string || 客户端会话描述 |
| RequestId | string || 请求 ID,业务自定义生成,可用于业务区分不同请求 |
| Sign | string | 开启校验则必要 | 请求校验参数<br>计算方式:SHA256(字段名排序后取字段值,并拼接成字符串,最后再拼接上签名混淆密钥 SALT) |
| 字段 | 类型 | 必要 | 描述 |
| -------------------- | ------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| UserId | string || 用户 ID,业务自定义生成,不同用户需要生成不同 UserId 来区分 |
| ProjectId | string || 项目 ID,应用云渲染项目创建时生成,[项目管理](https://console.cloud.tencent.com/car/project) 中获取,格式为 cap-xxx |
| ApplicationId | string || 应用 ID,多应用共享项目请求时有效,应用云渲染应用创建时生成,[应用管理](https://console.cloud.tencent.com/car/application) 中获取,格式为 app-xxx |
| ApplicationVersionId | string || 应用版本 ID,应用云渲染应用创建时生成,[应用管理](https://console.cloud.tencent.com/car/application) 中获取,格式为 ver-xxx |
| ClientSession | string || 客户端会话描述 |
| RequestId | string || 请求 ID,业务自定义生成,可用于业务区分不同请求 |
| Sign | string | 开启校验则必要 | 请求校验参数<br>计算方式:SHA256(字段名排序后取字段值,并拼接成字符串,最后再拼接上签名混淆密钥 SALT) |

- 响应

Expand Down Expand Up @@ -195,13 +196,14 @@ curl -X POST --data "ClientSession=xxx&RequestId=req123&UserId=userid123&Project

- 请求

| 字段 | 类型 | 必要 | 描述 |
| ------------- | ------ | -------------- | ------------------------------------------------------------------------------------------------------------------- |
| UserId | string || 用户 ID,业务自定义生成,不同用户需要生成不同 UserId 来区分 |
| ProjectId | string || 项目 ID,应用云渲染项目创建时生成,[项目管理](https://console.cloud.tencent.com/car/project) 中获取,格式为 cap-xxx |
| ApplicationId | string || 应用 ID,多应用共享项目请求时有效,应用云渲染应用创建时生成,[应用管理](https://console.cloud.tencent.com/car/application) 中获取,格式为 app-xxx |
| RequestId | string || 请求 ID,业务自定义生成,可用于业务区分不同请求 |
| Sign | string | 开启校验则必要 | 请求校验参数<br>计算方式:SHA256(字段名排序后取字段值,并拼接成字符串,最后再拼接上签名混淆密钥 SALT) |
| 字段 | 类型 | 必要 | 描述 |
| -------------------- | ------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| UserId | string || 用户 ID,业务自定义生成,不同用户需要生成不同 UserId 来区分 |
| ProjectId | string || 项目 ID,应用云渲染项目创建时生成,[项目管理](https://console.cloud.tencent.com/car/project) 中获取,格式为 cap-xxx |
| ApplicationId | string || 应用 ID,多应用共享项目请求时有效,应用云渲染应用创建时生成,[应用管理](https://console.cloud.tencent.com/car/application) 中获取,格式为 app-xxx |
| ApplicationVersionId | string || 应用版本 ID,应用云渲染应用创建时生成,[应用管理](https://console.cloud.tencent.com/car/application) 中获取,格式为 ver-xxx |
| RequestId | string || 请求 ID,业务自定义生成,可用于业务区分不同请求 |
| Sign | string | 开启校验则必要 | 请求校验参数<br>计算方式:SHA256(字段名排序后取字段值,并拼接成字符串,最后再拼接上签名混淆密钥 SALT) |

- 响应

Expand Down
11 changes: 10 additions & 1 deletion routes/car.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ if (Config.configs[DefaultKeys.API_SIGN] == 'Y') {
UserId: validSchema(validString, true),
ProjectId: validSchema(validString, true),
ApplicationId: validSchema(validString, false),
ApplicationVersionId: validSchema(validString, false),
ClientSession: validSchema(validString, true),
Sign: validSchema(validString, true),
},
Expand All @@ -53,6 +54,7 @@ if (Config.configs[DefaultKeys.API_SIGN] == 'Y') {
UserId: validSchema(validString, true),
ProjectId: validSchema(validString, true),
ApplicationId: validSchema(validString, false),
ApplicationVersionId: validSchema(validString, false),
Sign: validSchema(validString, true),
},
'/Dequeue': {
Expand All @@ -67,6 +69,7 @@ if (Config.configs[DefaultKeys.API_SIGN] == 'Y') {
UserId: validSchema(validString, true),
ProjectId: validSchema(validString, true),
ApplicationId: validSchema(validString, false),
ApplicationVersionId: validSchema(validString, false),
ClientSession: validSchema(validString, true),
},
'/StopProject': {
Expand All @@ -76,6 +79,7 @@ if (Config.configs[DefaultKeys.API_SIGN] == 'Y') {
UserId: validSchema(validString, true),
ProjectId: validSchema(validString, true),
ApplicationId: validSchema(validString, false),
ApplicationVersionId: validSchema(validString, false),
},
'/Dequeue': {
UserId: validSchema(validString, true),
Expand All @@ -98,6 +102,7 @@ router.post('/StartProject', verifyReqParams, verifySign, async (req, res, next)
UserIp: userIp,
ProjectId: params.ProjectId,
ApplicationId: params.ApplicationId,
ApplicationVersionId: params.ApplicationVersionId,
});
if (ret.Code != 0) {
simpleRespone(req, res, ret);
Expand Down Expand Up @@ -149,6 +154,7 @@ const doCheckQueue = async key => {
UserId: item.UserId,
ProjectId: item.ProjectId,
ApplicationId: item.ApplicationId,
ApplicationVersionId: item.ApplicationVersionId,
UserIp: item.UserIp
};
waitQueue[key].State = QueueState.Locking;
Expand All @@ -174,6 +180,7 @@ router.post('/Enqueue', verifyReqParams, verifySign, async (req, res, next) => {
const UserId = Params.UserId;
const ProjectId = Params.ProjectId;
const ApplicationId = Params.ApplicationId;
const ApplicationVersionId = Params.ApplicationVersionId;
const UserIp = getClientIp(req);

const response = (item, index) => {
Expand All @@ -197,6 +204,7 @@ router.post('/Enqueue', verifyReqParams, verifySign, async (req, res, next) => {
waitQueue[UserId].TimeStamp = Date.now();
waitQueue[UserId].ProjectId = ProjectId;
waitQueue[UserId].ApplicationId = ApplicationId;
waitQueue[UserId].ApplicationVersionId = ApplicationVersionId;
LOG.debug(`${UserId} update timestamp`);
return response(waitQueue[UserId], await queue.indexOf(UserId));
}
Expand All @@ -205,12 +213,13 @@ router.post('/Enqueue', verifyReqParams, verifySign, async (req, res, next) => {
UserId,
ProjectId,
ApplicationId,
ApplicationVersionId,
UserIp,
TimeStamp: Date.now(),
State: QueueState.Wait,
};
try {
await applyConcurrent({ UserId: UserId, ProjectId: ProjectId, ApplicationId: ApplicationId, UserIp: UserIp });
await applyConcurrent({ UserId: UserId, ProjectId: ProjectId, ApplicationId: ApplicationId, ApplicationVersionId: ApplicationVersionId, UserIp: UserIp });
newUser.State = QueueState.Done;
newUser.TimeStamp = Date.now();
LOG.debug(`${UserId} ready to play`);
Expand Down

0 comments on commit b47b73c

Please sign in to comment.