# `T3.WebSocket`
[🔗](https://github.com/dl-alexandre/t3-elixir/blob/main/lib/t3/web_socket.ex#L1)

Raw WebSocket transport for T3's non-Effect media/device routes.

Text and binary frames are delivered unchanged as
`{:t3_web_socket, socket, delivery_ref, {:text | :binary, bytes}}`. Call
`ack/2` after consuming each delivery. This acknowledgement only releases the
local backlog; route-specific acknowledgements (for example preview's JSON
`{"type":"ack"}`) must also be sent to the server. See `T3.WebSocket.Routes`.

Credentials are explicit: `:token` adds Authorization, `:ticket` adds wsTicket,
and `:headers`/`:query` admit other route-specific inputs. No authentication is
inferred from an MCP client. WSS is required except on loopback. A credential
is sent only to the configured URL; redirects are never followed.

Options: `:owner` (defaults to starter), `:connect_timeout` (10 seconds),
`:idle_timeout` (60 seconds; `:infinity` allowed), `:lifetime` (`:infinity`),
`:max_message_bytes` (16 MiB), `:max_pending_frames` (16), and
`:max_pending_bytes` (32 MiB). Exceeding an input/backlog bound closes the
connection and reports an error rather than accumulating unbounded mail.
Ping frames receive automatic pongs. Owner death closes the connection.
Server-close messages are `{:t3_web_socket, socket, {:closed, reason}}`;
failures additionally send `{:t3_web_socket, socket, {:error, %T3.Error{}}}`.

# `ack`

Release a consumed delivery from the local backlog; sends nothing to the server.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

Close the socket and release resources. Safe to call repeatedly.

# `ping`

# `pong`

# `send_binary`

Send literal binary bytes, such as a route-specific control/video payload.

# `send_json`

Encode a value as JSON and send it in a text frame.

# `send_text`

Send a literal text frame. No JSON encoding or protocol envelope is added.

# `start_link`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
