> ## 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

> Wysyła Lua string przez WebSocket object zwrócony przez WebSocket.connect. Method oczekuje WebSocket table jako pierwszego argument i message string jako drugiego argument. Odczytuje connection state obiektu, rzuca "WebSocket state is missing", jeśli tego object nie ma, wraca bez wysyłania, gdy state jest destroyed lub closed, i wywołuje curl_ws_send z CURLWS_TEXT domyślnie albo z CURLWS_BINARY, gdy opcjonalny trzeci argument to boolean true. Nie zwraca values i nie raportuje liczby wysłanych bytes.

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

  ## Argumenty

  <ParamField path={"socket"} type={"WebSocket"} required>
    WebSocket table zwrócona przez WebSocket.connect. Send jest rozwiązywane przez WebSocket object methods, więc udokumentowana forma wywołania to socket:Send(..).
  </ParamField>

  <ParamField path={"message"} type={"string"} required>
    Lua string payload przekazywany do curl\_ws\_send wraz z explicit byte length.
  </ParamField>

  <ParamField path={"isBinary"} type={"boolean"}>
    Gdy ten argument istnieje i ma wartość true, Send używa CURLWS\_BINARY. W przeciwnym razie używa CURLWS\_TEXT.
  </ParamField>

  ## Przykład

  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>
