# `Plushie.Test.SessionPool.Multiplexed`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/test/session_pool/multiplexed.ex#L1)

State and business logic for the shared-renderer session pool modes.

`:mock` and `:headless` run one renderer process that hosts many logical
sessions. This module owns the registrations, pending replies, teardown
tracking, and dispatch of replies back to the correct test process.

# `request_id`

```elixir
@type request_id() :: String.t()
```

Request identifier attached to a message sent to the renderer.

# `session_id`

```elixir
@type session_id() :: String.t()
```

Internal session identifier assigned by `SessionPool`.

# `t`

```elixir
@type t() :: %Plushie.Test.SessionPool.Multiplexed{
  buffer: binary(),
  pending: %{
    required({session_id(), request_id()}) =&gt; {String.t(), GenServer.from()}
  },
  pending_close: %{required(session_id()) =&gt; :awaiting},
  port: port(),
  sessions: %{required(session_id()) =&gt; {pid(), reference()}}
}
```

Shared-renderer state for multiplexed test sessions.

# `find_session_by_owner`

```elixir
@spec find_session_by_owner(t(), pid(), reference()) ::
  {session_id(), {pid(), reference()}} | nil
```

# `handle_port_data`

```elixir
@spec handle_port_data(
  binary() | {:eol, binary()},
  t(),
  Plushie.Test.SessionPool.Transport.format()
) ::
  t()
```

# `handle_renderer_exit`

```elixir
@spec handle_renderer_exit(t()) :: t()
```

# `register`

```elixir
@spec register(t(), session_id(), pid(), reference()) :: t()
```

# `release_session`

```elixir
@spec release_session(
  t(),
  session_id(),
  request_id(),
  Plushie.Test.SessionPool.Transport.format()
) ::
  t()
```

# `send_async`

```elixir
@spec send_async(
  t(),
  session_id(),
  map(),
  Plushie.Test.SessionPool.Transport.format()
) :: t()
```

# `send_interact`

```elixir
@spec send_interact(
  t(),
  session_id(),
  map(),
  request_id(),
  Plushie.Test.SessionPool.Transport.format()
) ::
  {:ok, t()} | :error
```

# `send_sync`

```elixir
@spec send_sync(
  t(),
  session_id(),
  map(),
  request_id(),
  String.t(),
  GenServer.from(),
  Plushie.Test.SessionPool.Transport.format()
) :: {:ok, t()} | :error
```

# `session_count`

```elixir
@spec session_count(t()) :: non_neg_integer()
```

# `unregister`

```elixir
@spec unregister(
  t(),
  session_id(),
  request_id(),
  GenServer.from(),
  Plushie.Test.SessionPool.Transport.format()
) :: t()
```

---

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