# `Cauldron2D.Sessions`
[🔗](https://github.com/jaman/cauldron/blob/v0.3.3/cauldron_2d/lib/cauldron_2d/sessions.ex#L1)

Who is logged in on the node, by whatever kind of client, told to whoever asks.

    Cauldron2D.Sessions.track("alice", :terminal)
    Cauldron2D.Sessions.list()
    #=> [%{id: "alice", kind: :terminal, since: 1789718400, pid: #PID<0.312.0>}]
    Cauldron2D.Sessions.subscribe()
    receive do
      {:cauldron_sessions, :opened, session} -> ...
      {:cauldron_sessions, :closed, session} -> ...
    end

A session is the calling process — a client on an ssh connection, a page in a
browser — listed from `track/2` until the process exits or tracks again. `kind` is
whatever the client calls itself. A subscribed process hears every opening and closing
until it unsubscribes or exits.

# `session`

```elixir
@type session() :: %{id: term(), kind: atom(), since: integer(), pid: pid()}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `list`

```elixir
@spec list() :: [session()]
```

Every session on the node, oldest first.

# `subscribe`

```elixir
@spec subscribe() :: :ok
```

Receive every opening and closing in the calling process.

# `track`

```elixir
@spec track(term(), atom()) :: :ok
```

List the calling process as a session of `id`, of this `kind`, until it exits.

# `unsubscribe`

```elixir
@spec unsubscribe() :: :ok
```

Stop receiving them.

---

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