# `Caracola.Call`
[🔗](https://github.com/netkubes/caracola/blob/v0.1.0-rc.1/lib/caracola/call.ex#L1)

Call process: every request, response and transaction with the same
Call-ID is handled by a single process, which serializes all the work for
that call. Equivalent to NkSIP's `nksip_call_srv` and `nksip_router`.

Call processes are started on demand, registered in a `Registry` of the
service (which also enforces `max_calls`) and stop when they have no
transactions or dialogs left. User callbacks run inside the call process and receive this
struct as the `call` argument.

A process may stop right after a caller found it; in that case the work
had not been received, and it is sent again to a new process.

# `t`

```elixir
@type t() :: %Caracola.Call{
  auths: MapSet.t(),
  call_id: String.t(),
  config: keyword(),
  dialogs: %{required(Caracola.Dialog.id()) =&gt; Caracola.Dialog.t()},
  events: MapSet.t(),
  forks: %{required(pos_integer()) =&gt; term()},
  hibernate: term(),
  msgs: %{required(String.t()) =&gt; pos_integer()},
  next: pos_integer(),
  service: module(),
  start_time: term(),
  trans: %{required(pos_integer()) =&gt; term()}
}
```

The state of a call: all the transactions, forks and dialogs sharing a Call-ID, owned by one process per service and Call-ID.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `count`

```elixir
@spec count(module()) :: non_neg_integer()
```

Returns the number of calls of a service.

# `find`

```elixir
@spec find(module(), String.t()) :: pid() | nil
```

Returns the pid of a call process, if started.

# `work`

```elixir
@spec work(module(), String.t(), term(), timeout()) :: term()
```

Sends a piece of work to the process of a call, starting it if needed.

---

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