# `RTMP.Connection`
[🔗](https://github.com/Adeyeye93/rtmp/blob/v0.1.0/lib/rtmp/connection.ex#L1)

One process per RTMP connection (a `ThousandIsland.Handler`). Started by
`RTMP.Listener`; you don't use this module directly.

It drives the whole connection: handshake, chunk stream reassembly,
protocol control messages, commands, FLV tag parsing, and the calls into
your `RTMP.Handler`.

## Design notes

  * **Backpressure.** Frames are handed to your handler synchronously,
    inside `handle_data/3`. ThousandIsland keeps the socket in
    `active: :once` mode, so no more data is read until that returns. A
    slow handler throttles the publisher through TCP flow control instead
    of filling an internal queue — there isn't one.
  * **Failure isolation.** Every exit path — protocol error, limit breach,
    timeout, handler exception, rejection — closes this one connection
    and reports a reason to `c:RTMP.Handler.handle_disconnect/2`. Nothing
    here can affect the listener or other connections.
  * **Output batching.** Everything a step needs to send is collected and
    written to the socket in one call at the end of that step.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

```elixir
@spec start_link({handler_options :: term(), GenServer.options()}) ::
  GenServer.on_start()
```

---

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