{
  "protocol": "websocket",
  "version": "1.0.0",
  "title": "Signaling Server WebSocket API",
  "description": "WebSocket API for peer-to-peer signaling between hosts and clients",
  "connection": {
    "url": "ws://localhost:5052/ws",
    "description": "WebSocket connection endpoint"
  },
  "messageFormat": {
    "type": "json",
    "schema": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Message type"
        },
        "hostId": {
          "type": "string",
          "description": "Host identifier"
        },
        "clientId": {
          "type": "string",
          "description": "Client identifier"
        },
        "payload": {
          "type": "string",
          "description": "Message payload"
        }
      },
      "required": [
        "type"
      ]
    }
  },
  "messageTypes": {
    "host": {
      "description": "Register a new host",
      "direction": "client_to_server",
      "request": {
        "type": "host"
      },
      "response": {
        "type": "host",
        "hostId": "generated-host-id"
      }
    },
    "joinHost": {
      "description": "Client joins a host",
      "direction": "client_to_server",
      "request": {
        "type": "join-host",
        "hostId": "target-host-id"
      },
      "response": {
        "type": "join-host",
        "hostId": "target-host-id",
        "clientId": "generated-client-id"
      }
    },
    "clientJoined": {
      "description": "Server notifies host that a client joined",
      "direction": "server_to_client",
      "response": {
        "type": "client-joined",
        "hostId": "abc123",
        "clientId": "xyz456"
      }
    },
    "msgToHost": {
      "description": "Client sends message to host",
      "direction": "client_to_server",
      "request": {
        "type": "msg-to-host",
        "payload": "message-content"
      },
      "response": "No direct response - message forwarded to host"
    },
    "msgToClient": {
      "description": "Host sends message to client",
      "direction": "server_to_client",
      "request": {
        "type": "msg-to-client",
        "clientId": "target-client-id",
        "payload": "message-content"
      },
      "response": "No direct response - message forwarded to client"
    },
    "clientDisconnected": {
      "description": "Server notifies host that a client disconnected",
      "direction": "server_to_client",
      "response": {
        "type": "client-disconnected",
        "hostId": "abc123",
        "clientId": "xyz456"
      }
    },
    "hostDisconnected": {
      "description": "Server notifies all clients that host disconnected",
      "direction": "server_to_client",
      "response": {
        "type": "host-disconnected",
        "hostId": "abc123"
      }
    }
  },
  "errorFormat": {
    "type": "error",
    "message": "Error description"
  },
  "examples": {
    "registerHost": {
      "request": "{\u0022type\u0022:\u0022host\u0022}",
      "response": "{\u0022type\u0022:\u0022host\u0022,\u0022hostId\u0022:\u0022abc123\u0022}"
    },
    "joinHost": {
      "request": "{\u0022type\u0022:\u0022join-host\u0022,\u0022hostId\u0022:\u0022abc123\u0022}",
      "response": "{\u0022type\u0022:\u0022join-host\u0022,\u0022hostId\u0022:\u0022abc123\u0022,\u0022clientId\u0022:\u0022xyz456\u0022}"
    },
    "clientJoinedNotification": {
      "response": "{\u0022type\u0022:\u0022client-joined\u0022,\u0022hostId\u0022:\u0022abc123\u0022,\u0022clientId\u0022:\u0022xyz456\u0022}"
    },
    "sendMessageToHost": {
      "request": "{\u0022type\u0022:\u0022msg-to-host\u0022,\u0022payload\u0022:\u0022Hello host!\u0022}",
      "response": "No direct response"
    },
    "sendMessageToClient": {
      "request": "{\u0022type\u0022:\u0022msg-to-client\u0022,\u0022clientId\u0022:\u0022xyz456\u0022,\u0022payload\u0022:\u0022Hello client!\u0022}",
      "response": "No direct response"
    },
    "clientDisconnectedNotification": {
      "response": "{\u0022type\u0022:\u0022client-disconnected\u0022,\u0022hostId\u0022:\u0022abc123\u0022,\u0022clientId\u0022:\u0022xyz456\u0022}"
    },
    "hostDisconnectedNotification": {
      "response": "{\u0022type\u0022:\u0022host-disconnected\u0022,\u0022hostId\u0022:\u0022abc123\u0022}"
    }
  }
}