> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# WebSocket.Send

> Envía un Lua string mediante un WebSocket object devuelto por WebSocket.connect. La method espera la WebSocket table como primer argument y el message string como segundo argument. Lee el connection state del object, lanza "WebSocket state is missing" si esa object no existe, vuelve sin enviar cuando el state está destroyed o closed, y llama a curl_ws_send con CURLWS_TEXT por defecto o con CURLWS_BINARY cuando el tercer argument opcional es boolean true. No devuelve values ni informa la cantidad de bytes enviados.

<div className="real-function-page">
  ```lua theme={null}
  WebSocket.Send(socket: WebSocket, message: string, isBinary?: boolean)
  ```

  ## Argumentos

  <ParamField path={"socket"} type={"WebSocket"} required>
    WebSocket table devuelta por WebSocket.connect. Send se resuelve desde la WebSocket object methods, por eso la forma documentada de llamada es socket:Send(..).
  </ParamField>

  <ParamField path={"message"} type={"string"} required>
    Lua string payload que se pasa a curl\_ws\_send con su explicit byte length.
  </ParamField>

  <ParamField path={"isBinary"} type={"boolean"}>
    Cuando este argument está presente y es true, Send usa CURLWS\_BINARY. De lo contrario usa CURLWS\_TEXT.
  </ParamField>

  ## Ejemplo

  Send text or binary data through a WebSocket object returned by WebSocket.connect.

  ```lua theme={null}
  local socket = WebSocket.connect("wss://example.com/socket")

  socket:Send("hello")
  socket:Send(string.char(0, 1, 2, 3), true)
  ```
</div>
