CallClient | sinch-rtc
Description: Documentation for sinch-rtc

# Interface CallClient

interface CallClient {
addListener(listener: CallClientListener): void;
callConference(
conferenceId: string,
headers?: Record<string, string>,
): Promise<Call>;
callPhoneNumber(
phoneNumber: string,
headers?: Record<string, string>,
): Promise<Call>;
callSip(
sipIdentity: string,
headers?: Record<string, string>,
): Promise<Call>;
callUser(toUserId: string, headers?: Record<string, string>): Promise<Call>;
callUserVideo(
toUserId: string,
headers?: Record<string, string>,
): Promise<Call>;
getCall(callId: string): undefined | Call;
removeListener(listener: CallClientListener): void;
setAudioTrackConstraints(constraints: null | MediaTrackConstraints): void;
setVideoTrackConstraints(constraints: null | MediaTrackConstraints): void;
}

##### Index

### Methods

addListener
callConference
callPhoneNumber
callSip
callUser
callUserVideo
getCall
removeListener
setAudioTrackConstraints
setVideoTrackConstraints

## Methods

### addListener

- addListener(listener: CallClientListener): void

  The CallClientListener object will be notified of new incoming calls.

  #### Parameters

  - listener: CallClientListener

    a CallClientListener

  #### Returns void

### callConference

- callConference(
  conferenceId: string,
  headers?: Record<string, string>,
  ): Promise<Call>

  Calls the conference with the given id and the given headers.

  #### Parameters

  - conferenceId: string

    Conference ID to dial in to.

  - `Optional`headers: Record<string, string>

    Headers to pass with the call.

  #### Returns Promise<Call>

  A Call instance.

  #### Throws

  InvalidOperationError if SinchClient is not started

  #### Throws

  ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.

### callPhoneNumber

- callPhoneNumber(
  phoneNumber: string,
  headers?: Record<string, string>,
  ): Promise<Call>

  Calls a phone number and terminates the call to the PSTN-network (Publicly Switched Telephone Network).

  #### Parameters

  - phoneNumber: string

    The phone number to call. The phone number should be given according to E.164 number formatting (http://en.wikipedia.org/wiki/E.164) and should be prefixed with a '+'. E.g. to call the US phone number 415 555 0101, it should be specified as "+14155550101", where the '+' is the required prefix and the US country code '1' added before the local subscriber number.

  - `Optional`headers: Record<string, string>

    Headers to pass with the call.

  #### Returns Promise<Call>

  A Call instance.

  #### Throws

  InvalidOperationError if SinchClient is not started

  #### Throws

  ArgumentError if conferenceId exceeds 64 characters

  #### Throws

  ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.

### callSip

- callSip(sipIdentity: string, headers?: Record<string, string>): Promise<Call>

  Makes a SIP call to the user with the given identity. The identity should be in the form "sip:user@server".

  #### Parameters

  - sipIdentity: string

    SIP identity to dial in to.

  - `Optional`headers: Record<string, string>

  #### Returns Promise<Call>

  A Call instance.

  #### Throws

  InvalidOperationError if SinchClient is not started

  #### Throws

  ArgumentError if sipIdentity exceeds 64 characters

  #### Throws

  ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.

### callUser

- callUser(toUserId: string, headers?: Record<string, string>): Promise<Call>

  Makes a call to the user with the given id.

  #### Parameters

  - toUserId: string

    The app specific id of the user to call. May not be null or empty.

  - `Optional`headers: Record<string, string>

    Headers to pass with the call.

  #### Returns Promise<Call>

  A Call instance.

  #### Throws

  InvalidOperationError if SinchClient is not started

  #### Throws

  ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.

### callUserVideo

- callUserVideo(toUserId: string, headers?: Record<string, string>): Promise<Call>

  Makes a video call to the user with the given id and adding the given headers.

  #### Parameters

  - toUserId: string

    The app specific id of the user to call. May not be null or empty.

  - `Optional`headers: Record<string, string>

    Headers to pass with the call.

  #### Returns Promise<Call>

  A Call instance.

  #### Throws

  InvalidOperationError if SinchClient is not started

  #### Throws

  ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.

### getCall

- getCall(callId: string): undefined | Call

  Returns the Call object with the identifier `callId`.

  #### Parameters

  - callId: string

    The call identifier string.

  #### Returns undefined | Call

  A Call instance if one matches, otherwise `undefined`.

### removeListener

- removeListener(listener: CallClientListener): void

  Remove listener for incoming call events.

  #### Parameters

  - listener: CallClientListener

    a CallClientListener

  #### Returns void

### setAudioTrackConstraints

- setAudioTrackConstraints(constraints: null | MediaTrackConstraints): void

  Sets or removes audio track constraints that are applied to ongoing calls and will also be used for any new Call created.

  #### Parameters

  - constraints: null | MediaTrackConstraints

    The constraints to apply for the audio track:

    - Provide a MediaTrackConstraints object to apply specific constraints (e.g. `{ deviceId: { exact: "mic-id" }, echoCancellation: true }`).
    - Pass `null` to remove previously set constraints, falling back to the default device when requesting audio.

  #### Returns void

  #### Example

      callClient.setAudioTrackConstraints({ echoCancellation: true });
      callClient.setAudioTrackConstraints(null); // remove constraints, use default device

### setVideoTrackConstraints

- setVideoTrackConstraints(constraints: null | MediaTrackConstraints): void

  Sets or removes video track constraints that are applied to ongoing calls and will also be used for any new Call created.

  #### Parameters

  - constraints: null | MediaTrackConstraints

    The constraints to apply for the video track:

    - Provide a MediaTrackConstraints object to apply specific constraints (e.g. `{ width: 1280, height: 720 }`).
    - Pass `null` to remove previously set constraints, falling back to default constraints.

  #### Returns void

  #### Example

      callClient.setVideoTrackConstraints({ width: 1280, height: 720 });
      callClient.setVideoTrackConstraints(null); // remove constraints, use default/fallback