69 lines
2.3 KiB
Go
69 lines
2.3 KiB
Go
// Package lobby defines the public typed command and response payloads
|
|
// exposed at the authenticated Gateway -> Game Lobby boundary.
|
|
package lobby
|
|
|
|
import "time"
|
|
|
|
const (
|
|
// MessageTypeMyGamesList is the authenticated gateway message type
|
|
// used to read the calling user's own games.
|
|
MessageTypeMyGamesList = "lobby.my.games.list"
|
|
|
|
// MessageTypeOpenEnrollment is the authenticated gateway message
|
|
// type used by the game owner to transition a draft game to
|
|
// `enrollment_open`.
|
|
MessageTypeOpenEnrollment = "lobby.game.open-enrollment"
|
|
)
|
|
|
|
// MyGamesListRequest stores the authenticated read request for the
|
|
// caller's games. The request body is intentionally empty; gateway
|
|
// derives the calling user identity from the verified session.
|
|
type MyGamesListRequest struct{}
|
|
|
|
// MyGamesListResponse stores the list of games the caller participates
|
|
// in, ordered as Lobby returns them.
|
|
type MyGamesListResponse struct {
|
|
Items []GameSummary `json:"items"`
|
|
}
|
|
|
|
// GameSummary stores one game record returned by `lobby.my.games.list`.
|
|
type GameSummary struct {
|
|
GameID string `json:"game_id"`
|
|
GameName string `json:"game_name"`
|
|
GameType string `json:"game_type"`
|
|
Status string `json:"status"`
|
|
OwnerUserID string `json:"owner_user_id"`
|
|
MinPlayers int `json:"min_players"`
|
|
MaxPlayers int `json:"max_players"`
|
|
EnrollmentEndsAt time.Time `json:"enrollment_ends_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// OpenEnrollmentRequest stores the owner-only command that transitions
|
|
// a game from `draft` to `enrollment_open`.
|
|
type OpenEnrollmentRequest struct {
|
|
// GameID identifies the game whose enrollment the caller wants to
|
|
// open. The owner check is enforced by Lobby.
|
|
GameID string `json:"game_id"`
|
|
}
|
|
|
|
// OpenEnrollmentResponse stores the resulting game record after a
|
|
// successful open-enrollment transition.
|
|
type OpenEnrollmentResponse struct {
|
|
GameID string `json:"game_id"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
// ErrorBody stores the canonical Lobby error envelope code/message
|
|
// pair.
|
|
type ErrorBody struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// ErrorResponse wraps ErrorBody for the FlatBuffers payload boundary.
|
|
type ErrorResponse struct {
|
|
Error ErrorBody `json:"error"`
|
|
}
|