# `ExCEP.Cluster.Session`

Per-gateway TCP/TLS connection session on the Cluster (Master) server.

Executes the server side of Section 5 three-way SM2 authentication, registers the
authenticated `gateway_id` with `ExCEP.Cluster.Server`, correlates Cluster -> Gateway
requests by `Head/Mid`, and dispatches Gateway -> Cluster reports to `ExCEP.Cluster.Handler`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

```elixir
@spec close(pid()) :: :ok
```

Closes the session (idempotent if already stopped).

# `pull_file`

```elixir
@spec pull_file(pid(), String.t(), keyword()) :: {:ok, binary()} | {:error, term()}
```

Pulls a file from the Gateway using Section 6.2.1 `FileGet` + `FileDataTrans`.

# `request`

```elixir
@spec request(pid(), ExCEP.Codec.DataAsdu.t(), keyword()) ::
  {:ok, ExCEP.Codec.DataAsdu.t()} | {:error, term()}
```

Sends a `%DataAsdu{}` request from the Cluster to this Gateway and awaits its response.

# `send_asdu`

```elixir
@spec send_asdu(pid(), ExCEP.Codec.DataAsdu.t(), keyword()) :: :ok | {:error, term()}
```

Sends a `%DataAsdu{}` from the Cluster to this Gateway without waiting for a response.

# `start`

```elixir
@spec start(keyword()) :: GenServer.on_start()
```

Starts an unlinked session process (used by `ExCEP.Cluster.Server` for fault isolation).

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

---

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