> For the complete documentation index, see [llms.txt](https://digitalsac.gitbook.io/digicalls/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://digitalsac.gitbook.io/digicalls/digicalls-sdk/chamadas/chamada-ativa.md).

# Chamada ativa

Objeto `Call` retornado por `offer.accept()` ou disponível após `onPeerAccept` em chamada outbound.

### Propriedades

| Campo       | Descrição                                                               |
| ----------- | ----------------------------------------------------------------------- |
| `callId`    | Identificador                                                           |
| `sessionId` | Sessão                                                                  |
| `peer`      | `{ phone, name?, avatar? }`                                             |
| `direction` | `"inbound"` \| `"outbound"`                                             |
| `token`     | Device token                                                            |
| `peerMuted` | `boolean` — interlocutor silenciou o microfone (**não** é o mute local) |

### Controles

```typescript
call.mute();    // silencia O NOSSO microfone (operador)
call.unmute();
await call.end();  // DELETE /api/sessions/{sid}/calls/{id}
```

{% hint style="info" %}
`peerMuted` / `onPeerMuteChange` referem-se ao microfone do **cliente no WhatsApp**. `mute()` / `unmute()` silenciam o microfone **deste** navegador.
{% endhint %}

### Eventos

```typescript
call.onEnd(({ reason }) => {
  cleanupUI();
});

call.onStateChange((state) => {
  // "accepted" | "ended"
});

call.onPeerMuteChange((muted) => {
  // true = cliente silenciou; false = reativou
});
```

### Encerramento remoto

Se o WhatsApp ou o peer desligar, o SSE envia `call-ended` e o SDK chama `onEnd`.

### Duração / histórico

Consulte histórico no servidor:

```
GET /api/sessions/{sid}/history
GET /api/devices/{token}/calls   (API key)
```

### Integração Izing

O store `webphone.js` mapeia status para vocabulário legado:

| DigiCalls        | UI Izing            |
| ---------------- | ------------------- |
| offer            | `offer`             |
| ringing outbound | `outcoming_calling` |
| connected        | `accept`            |
| ended            | `terminate`         |

Referência: `docs/izing/INTEGRACAO-WEBPHONE.md`.

### Exemplo completo

```typescript
function handleActiveCall(call: Call) {
  startTimer();

  document.getElementById("hangup")!.onclick = () => call.end();
  document.getElementById("mute")!.onclick = () => call.mute();

  call.onPeerMuteChange((muted) => {
    document.getElementById("peer-mute")!.hidden = !muted;
  });

  call.onEnd(() => stopTimer());
}
```
