Get Peer Connection
Web only
This method is only available in the JavaScript/TypeScript SDK.
Returns the underlying RTCPeerConnection for an active call leg. Use this to inspect or interact with the WebRTC peer connection after a call has been established.
Signature
const pc = client.getPeerConnection(callId);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
callId | string | Yes | The identifier of the active call |
Return Type
Returns RTCPeerConnection | undefined. Returns undefined if no peer connection exists for the given callId (e.g. the call has not yet been established or has already ended).
Usage Example
const pc = client.getPeerConnection('callId');
if (pc) {
console.log(`Connection state: ${pc.connectionState}`);
}Notes
- The peer connection is available from the point the call is answered/connected
- For the earliest possible access to the peer connection — before ICE gathering begins — use the
onPeerConnectionCreatedevent instead
Related Events
onPeerConnectionCreated- Fired immediately when the peer connection is instantiated, before ICE gathering