# `NodeWire.Client`
[🔗](https://github.com/c2bw/nodewire/blob/v0.1.0/lib/node_wire/client.ex#L1)

Persistent outbound client; sessions and handler state are fresh on reconnect.

# `status`

```elixir
@type status() :: %{
  state: :negotiated | :disconnected,
  connection: NodeWire.Conn.t() | nil,
  reason: atom() | NodeWire.Error.t() | nil
}
```

Latest asynchronous connection state, snapshot and failure reason.

# `child_spec`

```elixir
@spec child_spec(NodeWire.options()) :: Supervisor.child_spec()
```

Builds a child spec, validating the endpoint options. See `NodeWire`.

# `disconnect`

```elixir
@spec disconnect(GenServer.server()) :: :ok
```

Kills the current session and disables retries until `reconnect/1` is called.

This does not perform a graceful CLOSE exchange. Exits if the client is unavailable.

# `reconnect`

```elixir
@spec reconnect(GenServer.server()) :: :ok
```

Kills any existing session and starts a fresh asynchronous connection attempt.

Re-enables attempts after `disconnect/1` or a permanent failure. The configured
automatic reconnect policy still applies to later failures. Exits if unavailable.

# `send`

```elixir
@spec send(GenServer.server(), NodeWire.message(), NodeWire.send_options()) ::
  NodeWire.send_result()
```

Sends through the current connection; returns `:not_connected` if unavailable.

Accepts `:timeout_ms` (default 5,000) and `:on_sent` tracking tags, as in
`NodeWire.Server.send/4`. Messages are never automatically replayed after
reconnect. See `NodeWire` for local-write success and unknown outcomes.
Return send actions from handlers instead of synchronously sending to yourself.

# `start_link`

```elixir
@spec start_link(NodeWire.options()) :: GenServer.on_start()
```

Starts a linked persistent client using the endpoint options in `NodeWire`.

Connecting, authentication and readiness are asynchronous. Invalid
configuration raises; observe `status/1` for subsequent connection failures.
Handler state is initialized afresh on every connection attempt.

# `status`

```elixir
@spec status(GenServer.server()) :: status()
```

Returns the latest connection snapshot and failure reason.

`:negotiated` does not imply application readiness; inspect the snapshot's
phase. `:disconnected` also covers attempts in progress. Successful attempts
clear earlier reasons. Exits if the client process is unavailable.

---

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