Skip to main content

WebSocket Schema

For a more comprehensible view of the message types view this source file:

https://github.com/Capstone-Projects-2025-Spring/aac-go-fish/blob/main/backend/models.py

These message types are abstracted by Pydantics' model functionality and you do not need to deal with/format these messages directly as this is handled for you and is provided mostly for documentation purposes.

Websocket JSON Schema

Important

On connecting via the websocket endpoint, the first message MUST be the initializer!

Below is an autogenerated JSON schema viewer. The main messages types are the initializer message, game state updates, lobby lifecycle updates, and a chat message. The XOR chains specify the options under each message type and you can scroll sideways to view the other message types' options.

Loading ....

Source

This is the source for the above JSON schema viewer. This is the comprehensive JSON schema of all message types that are exchanged between the frontend and backend.

{
"$defs": {
"Burger": {
"description": "A burger.",
"properties": {
"ingredients": {
"items": {
"type": "string"
},
"title": "Ingredients",
"type": "array"
}
},
"required": [
"ingredients"
],
"title": "Burger",
"type": "object"
},
"Chat": {
"description": "The manager is typing.",
"properties": {
"type": {
"const": "chat",
"default": "chat",
"title": "Type",
"type": "string"
},
"typing": {
"title": "Typing",
"type": "boolean"
}
},
"required": [
"typing"
],
"title": "Chat",
"type": "object"
},
"DayEnd": {
"description": "No more orders for this day.",
"properties": {
"type": {
"const": "game_state",
"default": "game_state",
"title": "Type",
"type": "string"
},
"game_state_update_type": {
"const": "day_end",
"default": "day_end",
"title": "Game State Update Type",
"type": "string"
},
"day": {
"title": "Day",
"type": "integer"
},
"customers_served": {
"title": "Customers Served",
"type": "integer"
},
"score": {
"title": "Score",
"type": "integer"
}
},
"required": [
"day",
"customers_served",
"score"
],
"title": "DayEnd",
"type": "object"
},
"Drink": {
"description": "A drink.",
"properties": {
"color": {
"title": "Color",
"type": "string"
},
"fill": {
"title": "Fill",
"type": "number"
},
"size": {
"title": "Size",
"type": "string"
}
},
"required": [
"color",
"fill",
"size"
],
"title": "Drink",
"type": "object"
},
"GameEnd": {
"description": "All days are completed.",
"properties": {
"type": {
"const": "lobby_lifecycle",
"default": "lobby_lifecycle",
"title": "Type",
"type": "string"
},
"lifecycle_type": {
"const": "game_end",
"default": "game_end",
"title": "Lifecycle Type",
"type": "string"
}
},
"title": "GameEnd",
"type": "object"
},
"GameStart": {
"description": "The host starts the game.",
"properties": {
"type": {
"const": "lobby_lifecycle",
"default": "lobby_lifecycle",
"title": "Type",
"type": "string"
},
"lifecycle_type": {
"const": "game_start",
"default": "game_start",
"title": "Lifecycle Type",
"type": "string"
}
},
"title": "GameStart",
"type": "object"
},
"GameStateUpdate": {
"discriminator": {
"mapping": {
"day_end": "#/$defs/DayEnd",
"new_order": "#/$defs/NewOrder",
"order_component": "#/$defs/OrderComponent",
"order_score": "#/$defs/OrderScore",
"order_submission": "#/$defs/OrderSubmission",
"role_assignment": "#/$defs/RoleAssignment"
},
"propertyName": "game_state_update_type"
},
"oneOf": [
{
"$ref": "#/$defs/NewOrder"
},
{
"$ref": "#/$defs/RoleAssignment"
},
{
"$ref": "#/$defs/OrderScore"
},
{
"$ref": "#/$defs/OrderSubmission"
},
{
"$ref": "#/$defs/OrderComponent"
},
{
"$ref": "#/$defs/DayEnd"
}
]
},
"Initializer": {
"description": "Initializes player state.\n\nLinks the websocket connection to a specific player and lobby.\n\nAttributes:\n code: Lobby join code.\n id: Player id.",
"properties": {
"type": {
"const": "initializer",
"default": "initializer",
"title": "Type",
"type": "string"
},
"code": {
"items": {
"type": "string"
},
"title": "Code",
"type": "array"
},
"id": {
"title": "Id",
"type": "string"
}
},
"required": [
"code",
"id"
],
"title": "Initializer",
"type": "object"
},
"LifecycleEvent": {
"discriminator": {
"mapping": {
"game_end": "#/$defs/GameEnd",
"game_start": "#/$defs/GameStart",
"player_count": "#/$defs/PlayerCount",
"player_join": "#/$defs/PlayerJoin",
"player_leave": "#/$defs/PlayerLeave"
},
"propertyName": "lifecycle_type"
},
"oneOf": [
{
"$ref": "#/$defs/PlayerJoin"
},
{
"$ref": "#/$defs/PlayerLeave"
},
{
"$ref": "#/$defs/PlayerCount"
},
{
"$ref": "#/$defs/GameStart"
},
{
"$ref": "#/$defs/GameEnd"
}
]
},
"NewOrder": {
"description": "A new order for the manager.",
"properties": {
"type": {
"const": "game_state",
"default": "game_state",
"title": "Type",
"type": "string"
},
"game_state_update_type": {
"const": "new_order",
"default": "new_order",
"title": "Game State Update Type",
"type": "string"
},
"order": {
"$ref": "#/$defs/Order"
}
},
"required": [
"order"
],
"title": "NewOrder",
"type": "object"
},
"Order": {
"description": "A complete order.",
"properties": {
"burger": {
"anyOf": [
{
"$ref": "#/$defs/Burger"
},
{
"type": "null"
}
]
},
"drink": {
"anyOf": [
{
"$ref": "#/$defs/Drink"
},
{
"type": "null"
}
]
},
"side": {
"anyOf": [
{
"$ref": "#/$defs/Side"
},
{
"type": "null"
}
]
}
},
"required": [
"burger",
"drink",
"side"
],
"title": "Order",
"type": "object"
},
"OrderComponent": {
"description": "A finished component is submitted to the manager.",
"properties": {
"type": {
"const": "game_state",
"default": "game_state",
"title": "Type",
"type": "string"
},
"game_state_update_type": {
"const": "order_component",
"default": "order_component",
"title": "Game State Update Type",
"type": "string"
},
"component_type": {
"title": "Component Type",
"type": "string"
},
"component": {
"anyOf": [
{
"$ref": "#/$defs/Burger"
},
{
"$ref": "#/$defs/Side"
},
{
"$ref": "#/$defs/Drink"
}
],
"title": "Component"
}
},
"required": [
"component_type",
"component"
],
"title": "OrderComponent",
"type": "object"
},
"OrderScore": {
"description": "A score for the order.",
"properties": {
"type": {
"const": "game_state",
"default": "game_state",
"title": "Type",
"type": "string"
},
"game_state_update_type": {
"const": "order_score",
"default": "order_score",
"title": "Game State Update Type",
"type": "string"
},
"score": {
"title": "Score",
"type": "integer"
}
},
"required": [
"score"
],
"title": "OrderScore",
"type": "object"
},
"OrderSubmission": {
"description": "An order is submitted for review.",
"properties": {
"type": {
"const": "game_state",
"default": "game_state",
"title": "Type",
"type": "string"
},
"game_state_update_type": {
"const": "order_submission",
"default": "order_submission",
"title": "Game State Update Type",
"type": "string"
},
"order": {
"$ref": "#/$defs/Order"
}
},
"required": [
"order"
],
"title": "OrderSubmission",
"type": "object"
},
"PlayerCount": {
"description": "Current number of players in the lobby.",
"properties": {
"type": {
"const": "lobby_lifecycle",
"default": "lobby_lifecycle",
"title": "Type",
"type": "string"
},
"lifecycle_type": {
"const": "player_count",
"default": "player_count",
"title": "Lifecycle Type",
"type": "string"
},
"count": {
"title": "Count",
"type": "integer"
},
"player_ids": {
"items": {
"type": "string"
},
"title": "Player Ids",
"type": "array"
}
},
"required": [
"count"
],
"title": "PlayerCount",
"type": "object"
},
"PlayerJoin": {
"description": "A player joining a lobby.",
"properties": {
"type": {
"const": "lobby_lifecycle",
"default": "lobby_lifecycle",
"title": "Type",
"type": "string"
},
"lifecycle_type": {
"const": "player_join",
"default": "player_join",
"title": "Lifecycle Type",
"type": "string"
},
"id": {
"title": "Id",
"type": "string"
}
},
"required": [
"id"
],
"title": "PlayerJoin",
"type": "object"
},
"PlayerLeave": {
"description": "A player leaving a lobby.",
"properties": {
"type": {
"const": "lobby_lifecycle",
"default": "lobby_lifecycle",
"title": "Type",
"type": "string"
},
"lifecycle_type": {
"const": "player_leave",
"default": "player_leave",
"title": "Lifecycle Type",
"type": "string"
},
"id": {
"title": "Id",
"type": "string"
}
},
"required": [
"id"
],
"title": "PlayerLeave",
"type": "object"
},
"Role": {
"description": "Player roles.",
"enum": [
"manager",
"burger",
"drink",
"side"
],
"title": "Role",
"type": "string"
},
"RoleAssignment": {
"description": "Assign a role to the player.",
"properties": {
"type": {
"const": "game_state",
"default": "game_state",
"title": "Type",
"type": "string"
},
"game_state_update_type": {
"const": "role_assignment",
"default": "role_assignment",
"title": "Game State Update Type",
"type": "string"
},
"role": {
"$ref": "#/$defs/Role"
}
},
"required": [
"role"
],
"title": "RoleAssignment",
"type": "object"
},
"Side": {
"description": "A side.",
"properties": {
"table_state": {
"title": "Table State",
"type": "string"
}
},
"required": [
"table_state"
],
"title": "Side",
"type": "object"
}
},
"description": "Wrapper for message models.",
"properties": {
"data": {
"discriminator": {
"mapping": {
"chat": "#/$defs/Chat",
"game_state": "#/$defs/GameStateUpdate",
"initializer": "#/$defs/Initializer",
"lobby_lifecycle": "#/$defs/LifecycleEvent"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/Initializer"
},
{
"$ref": "#/$defs/GameStateUpdate"
},
{
"$ref": "#/$defs/LifecycleEvent"
},
{
"$ref": "#/$defs/Chat"
}
],
"title": "Data"
}
},
"required": [
"data"
],
"title": "Message",
"type": "object"
}