Call Features (PhoneOperator)
The PhoneOperator object is used for managing calls. Each call is cached
through the sessions attribute, which is a map containing different call
instances (Map<string, Session>), and each call instance is represented
as a Session. This topic describes the attributes, methods, and events
related to call features (PhoneOperator object).
Attributes
| Attributes | Type | Description |
|---|---|---|
| currentSessionID | string | ID of the current call (Session). |
| reRegistryPhoneTimes | number | Define the number of retry attempts for SIP UA (User Agent) registration. |
| deviceIds | { cameraId?: string; microphoneId?: string;} | IDs of the audio and video input devices, including the camera ID and microphone ID. |
| sessions | Map<string, Session> | Caching Map object for calls (Session), with the
callId as the key. |
| currentSession | Session | Current call. |
| isRegistered | boolean | Whether the SIP UA registration is successful. |
| extraHeaders | string[] | Additional SIP request headers. |
| videoPlan | string | Get video plan status. |
| recordPermissions | number | Call recording permission:
|
| incomingList | session[] | The list of the incoming calls. |
| isNoneCamera | boolean | Whether there is no camera. |
| isMaxCall | boolean | Whether the maximum number of concurrent calls has been reached. |
Methods
- Methods overview
- Listen for events
-
Method on(eventName:string,listener: (...args: any[]) => void)Parameters eventName: The event name.listener: Callback function.
Return value thisNote: For more information about the events that you can listen for, see Events.
- Start registering SIP UA
- After a successful SIP UA registration, users can make and receive
calls.Note: You need to listen for desired events before registering SIP UA. Otherwise, some events may be missed.
- Re-register SIP UA
-
Note: To avoid unexpected situations, use this method ONLY within the PhoneOperator object.
- Make a call
-
Method call(number: string, option?: CallOptions, transferId?: string)Parameters number: Callee number.option: Optional. Specify call options.transferId: Optional. ID of the attended transfer call.Note: If there is a value fortransferId, it indicates that this is an attended transfer call, which is an asynchronous function.
Return value Promise<Result>
- Reject a call
-
Method reject(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Answer a call
-
Method answer(callId: string, option?: CallOptions, allowNoneCamera: boolean = true)Parameters callId: The unique ID of the call.option: Optional. Specify call options.allowNoneCamera: Whether to allow answering without a camera.
Return value Promise<Result>
- Hang up a call
-
Method hangup(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Perform a blind transfer
-
Method blindTransfer(callId: string, number: string)Parameters callId: The unique ID of the call.number: The number of the transfer target.
Return value type boolean
- Perform an attended transfer
-
Method attendedTransfer(callId: string, number: string)Parameters callId: The unique ID of the call.number: The number of the transfer target.
Return value type boolean
- Hold a call
-
Method hold(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Resume a call
-
Method unhold(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Send DTMF
-
Method dtmf(callId: string, dtmf: string)Parameters callId: The unique ID of the call.dtmf: String (0123456789*#).
Return value type boolean
- Mute a call
-
Method mute(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Unmute a call
-
Method unmute(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Start recording
-
Method startRecord(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Pause recording
-
Method pauseRecord(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Terminate a call
-
Method terminate(callId: string, type: 'hangup' | 'reject' | 'terminate' = 'terminate')Parameters callId: The unique ID of the call.type: Types of call termination.
Return value type boolean
- Renegotiate a call
-
Method renegotiate(callId: string, offerToReceiveVideo?: boolean)Parameters callId: The unique ID of each call.offerToReceiveVideo: Whether to receive video.
Return value type boolean
- Switch audio to video
-
Method audioToVideo(callId: string, allowNoneCamera: boolean = true)Parameters callId: The unique ID of each call.allowNoneCamera: Whether to allow use without a camera.
Return value Promise<Result> - Switch video to audio
-
Method videoToAudio(callId: string)Parameters callId: The unique ID of each call.Return value type boolean
- Disconnect the SIP UA registration
-
Method disconnect()Parameters Null. Return value type boolean
- Retrieve all the calls (sessions attribute)
- Retrieve the
sessionsattribute and return them as an array.
- Set the current call (currentSession)
-
Method setCurrentSession(callId: string)Parameters callId: The unique ID of the call.Return value type boolean
- Retrieve the current call (currentSession)
-
Method getCurrentSession()Parameters Null. Return value Session
- Update the static properties of Session
-
Method setSessionStaticStatus(callId: string, staticStatus: Partial<StaticCallStatus>, startManualModel?: boolean)Parameters callId: The unique ID of the call.staticStatus: The static properties of Session includename,avatar, andcompany.startManualModel: Optional. Whether to enable manual mode. If enabled, the static properties will NOT be automatically updated.
Return value type boolean
- Destroy PhoneOperator object
- This method will cancel all the event subscriptions, stop the SIP UA instance, and delete all the sessions.
Events
| Event Name | Description | Report Parameter |
|---|---|---|
| connected | Connected to the SIP service. | Null |
| disconnected | Disconnected the SIP service. | Null |
| registered | SIP UA registration succeeded. | Null |
| registrationFailed | SIP UA registration failed. |
|
| newRTCSession | A new call instance (Session) is created. |
|
| incoming | There is an incoming call. |
|
| startSession | A call instance (Session) is added to the map that stores calls (sessions). |
|
| recordPermissionsChange | The recording permission is changed. |
|
| deleteSession | A call instance (Session) is deleted. |
|
| isRegisteredChange | Whether the SIP UA registration status is changed. |
|