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.
recordPermissions number Call recording permission:
  • 0: No permission
  • 1: Permission to pause / resume call recording
  • 2: Permission to start / pause / resume call recording
incomingList session[] The list of the incoming calls.
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 Null.
Note: 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.
Method
start()
Parameters Null.
Return value Null.
Re-register SIP UA
Note: To avoid unexpected situations, use this method ONLY within the PhoneOperator object.
Method
reRegister(authorizationUser: string, ha1: string)
Parameters
  • authorizationUser: User name.
  • ha1: Password.
Return value
this
Make a call
Method
call(number: string, option?: CallOptions, transferId?: string)
Parameters
  • number: Callee number.
  • option: Optional. Specify userMedia constraints.
  • transferId: Optional. ID of the attended transfer call.
    Note: If there is a value for transferId , 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)
Parameters
  • callId: The unique ID of the call.
  • option: Optional. Specify userMedia constraints.
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
Disconnect the SIP UA registration
Method
disconnect()
Parameters Null.
Return value type boolean
Retrieve all the calls (sessions attribute)
Retrieve the sessions attribute and return them as an array.
Method
getSession()
Parameters Null.
Return value type boolean
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 include name, avatar, and company.
  • 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.
Method
destroy()
Parameters Null.
Return value Null.

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.
  • code: number: Error code.
  • msg: string: Error message.
newRTCSession A new call instance (Session) is created.
  • callId: string: The unique ID of the call.
  • session: Session: The current call instance.
incoming There is an incoming call.
  • callId: string: The unique ID of the call.
  • session: Session:The current call instance.
startSession A call instance (Session) is added to the map that stores calls (sessions).
  • callId: string: The unique ID of the call.
  • session: Session: The current call instance.
recordPermissionsChange The recording permission is changed.
  • 0: No permission.
  • 1: Permission to pause / resume call recording.
  • 2: Permission to start / pause / resume call recording.
deleteSession A call instance (Session) is deleted.
  • callId: string: The unique ID of the call.
  • cause: string: Reason for deleting the call instance.
isRegisteredChange Whether the SIP UA registration status is changed.
  • true: Registration status changed.
  • false: Registration status did NOT change.