# `Lightstreamer.Transport`
[🔗](https://github.com/ktec/lightstreamer/blob/v0.1.0/lib/lightstreamer/transport.ex#L1)

Behaviour for the WebSocket transport under a `Lightstreamer.Session`.

A transport delivers inbound traffic to the process that called `c:connect/2`
as plain messages:

  * `{:transport, t, {:text, binary}}` — a chunk of inbound text; chunks may
    be fragmented or coalesced relative to server lines, so the session
    splits on CR-LF and buffers partial trailing lines
  * `{:transport, t, :closed}` — the connection is gone

The production implementation is `Lightstreamer.Transport.MintWs`; tests
drive a `Lightstreamer.Session` through a scripted stub instead. Swap via
the `:transport` option on `Lightstreamer.connect/2` — never app config.

# `t`

```elixir
@type t() :: term()
```

Opaque transport handle, defined by each implementation.

# `close`

```elixir
@callback close(t()) :: :ok
```

Closes the transport. Never sends `:closed` back to the owner.

# `connect`

```elixir
@callback connect(url :: String.t(), opts :: keyword()) :: {:ok, t()} | {:error, term()}
```

Synchronously opens the transport to `url` and completes any handshake.

The calling process becomes the owner and receives the inbound messages
described in the moduledoc.

# `send_text`

```elixir
@callback send_text(t(), iodata()) :: :ok | {:error, term()}
```

Sends one WebSocket text message.

---

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