Добавить API таймера экранов

This commit is contained in:
2026-09-21 17:59:25 +07:00
parent 0d32a6c4f1
commit a938dfa667
2 changed files with 116 additions and 32 deletions
+38
View File
@@ -656,6 +656,17 @@ service EveningDetectiveServer {
};
}
rpc SetScreenTimer(SetScreenTimerReq) returns (SetScreenTimerRsp) {
option (google.api.http) = {
post: "/api/games/{gameId}/screens/timer"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags : "Экраны";
summary: "Настроить таймер экранов";
};
}
// Отправить общую команду экранам игры.
rpc SendScreenCommand(SendScreenCommandReq) returns (SendScreenCommandRsp) {
option (google.api.http) = {
@@ -1425,6 +1436,15 @@ enum ScreenMode {
SCREEN_MODE_CONCLUSION = 4;
SCREEN_MODE_CONCLUSION_DONE = 5;
SCREEN_MODE_RESULTS = 6;
SCREEN_MODE_TIMER = 7;
}
enum ScreenTimerState {
SCREEN_TIMER_STATE_UNSPECIFIED = 0;
SCREEN_TIMER_STATE_STOPPED = 1;
SCREEN_TIMER_STATE_RUNNING = 2;
SCREEN_TIMER_STATE_PAUSED = 3;
SCREEN_TIMER_STATE_FINISHED = 4;
}
enum ScreenCommand {
@@ -1436,6 +1456,10 @@ enum ScreenCommand {
SCREEN_COMMAND_REPLAY = 5;
SCREEN_COMMAND_SEEK = 6;
SCREEN_COMMAND_VOLUME = 7;
SCREEN_COMMAND_TIMER_START = 8;
SCREEN_COMMAND_TIMER_PAUSE = 9;
SCREEN_COMMAND_TIMER_RESUME = 10;
SCREEN_COMMAND_TIMER_RESET = 11;
}
message ScreenState {
@@ -1454,6 +1478,10 @@ message ScreenState {
ScreenCommand command = 13;
int32 volume = 14;
string background_image = 15;
string timer_label = 16;
int64 timer_duration_seconds = 17;
int64 timer_remaining_seconds = 18;
ScreenTimerState timer_state = 19;
}
message CreateScreenSessionReq {}
@@ -1551,6 +1579,16 @@ message SetScreenModeRsp {
string error = 1;
}
message SetScreenTimerReq {
int32 gameId = 1;
int64 duration_seconds = 2;
string label = 3;
}
message SetScreenTimerRsp {
string error = 1;
}
message SendScreenCommandReq {
int32 gameId = 1;
ScreenCommand command = 2;
@@ -9,7 +9,14 @@ export type ScreenMode =
| "SCREEN_MODE_INTRO_DONE"
| "SCREEN_MODE_CONCLUSION"
| "SCREEN_MODE_CONCLUSION_DONE"
| "SCREEN_MODE_RESULTS";
| "SCREEN_MODE_RESULTS"
| "SCREEN_MODE_TIMER";
export type ScreenTimerState =
| "SCREEN_TIMER_STATE_UNSPECIFIED"
| "SCREEN_TIMER_STATE_STOPPED"
| "SCREEN_TIMER_STATE_RUNNING"
| "SCREEN_TIMER_STATE_PAUSED"
| "SCREEN_TIMER_STATE_FINISHED";
export type ScreenCommand =
| "SCREEN_COMMAND_UNSPECIFIED"
| "SCREEN_COMMAND_PLAY"
@@ -18,7 +25,11 @@ export type ScreenCommand =
| "SCREEN_COMMAND_STOP"
| "SCREEN_COMMAND_REPLAY"
| "SCREEN_COMMAND_SEEK"
| "SCREEN_COMMAND_VOLUME";
| "SCREEN_COMMAND_VOLUME"
| "SCREEN_COMMAND_TIMER_START"
| "SCREEN_COMMAND_TIMER_PAUSE"
| "SCREEN_COMMAND_TIMER_RESUME"
| "SCREEN_COMMAND_TIMER_RESET";
export type PingReq = {
};
@@ -520,6 +531,10 @@ export type ScreenState = {
command: ScreenCommand | undefined;
volume: number | undefined;
backgroundImage: string | undefined;
timerLabel: string | undefined;
timerDurationSeconds: number | undefined;
timerRemainingSeconds: number | undefined;
timerState: ScreenTimerState | undefined;
};
export type CreateScreenSessionReq = {
@@ -620,6 +635,16 @@ export type SetScreenModeRsp = {
error: string | undefined;
};
export type SetScreenTimerReq = {
gameId: number | undefined;
durationSeconds: number | undefined;
label: string | undefined;
};
export type SetScreenTimerRsp = {
error: string | undefined;
};
export type SendScreenCommandReq = {
gameId: number | undefined;
command: ScreenCommand | undefined;
@@ -1060,6 +1085,7 @@ export interface EveningDetectiveServer {
UpdateGameMapItem(request: UpdateGameMapItemReq): Promise<UpdateGameMapItemRsp>;
// Изменить общий режим показа всех экранов игры.
SetScreenMode(request: SetScreenModeReq): Promise<SetScreenModeRsp>;
SetScreenTimer(request: SetScreenTimerReq): Promise<SetScreenTimerRsp>;
// Отправить общую команду экранам игры.
SendScreenCommand(request: SendScreenCommandReq): Promise<SendScreenCommandRsp>;
GetScreenResults(request: GetScreenResultsReq): Promise<GetScreenResultsRsp>;
@@ -2172,6 +2198,26 @@ export function createEveningDetectiveServerClient(
method: "SetScreenMode",
}) as Promise<SetScreenModeRsp>;
},
SetScreenTimer(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.gameId) {
throw new Error("missing required field request.gameId");
}
const path = `api/games/${request.gameId}/screens/timer`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "SetScreenTimer",
}) as Promise<SetScreenTimerRsp>;
},
SendScreenCommand(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.gameId) {
throw new Error("missing required field request.gameId");