{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Matchfeed v1 server WebSocket control message",
  "type": "object",
  "oneOf": [
    {
      "properties": {
        "type": {
          "const": "ready"
        },
        "version": {
          "const": "1"
        }
      },
      "required": [
        "type",
        "version"
      ]
    },
    {
      "properties": {
        "type": {
          "const": "ack"
        },
        "op": {
          "enum": [
            "subscribe",
            "unsubscribe",
            "resync"
          ]
        }
      },
      "required": [
        "type",
        "op"
      ]
    },
    {
      "properties": {
        "type": {
          "const": "waiting"
        },
        "reason": {
          "const": "awaiting_snapshot"
        },
        "match_id": {
          "type": "string",
          "pattern": "^mf_[0-9a-f]{20}$"
        },
        "feed": {
          "enum": [
            "A",
            "B",
            "C"
          ]
        }
      },
      "required": [
        "type",
        "match_id",
        "feed"
      ]
    },
    {
      "properties": {
        "type": {
          "const": "reset"
        },
        "reason": {
          "const": "cursor_unavailable"
        },
        "match_id": {
          "type": "string",
          "pattern": "^mf_[0-9a-f]{20}$"
        },
        "feed": {
          "enum": [
            "A",
            "B",
            "C"
          ]
        }
      },
      "required": [
        "type",
        "reason",
        "match_id",
        "feed"
      ]
    },
    {
      "properties": {
        "type": {
          "const": "pong"
        }
      },
      "required": [
        "type"
      ]
    },
    {
      "properties": {
        "type": {
          "const": "error"
        },
        "match_id": {
          "type": "string"
        },
        "feed": {
          "type": "string"
        },
        "code": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "code"
      ]
    }
  ]
}
