Call Status and Call Features (Session)

The Session object is a call instance for managing call status and performing related operations during a call. This topic describes the attributes, methods, and events related to call status and call feature (Session object).

Attributes

Attributes Type Description
RTCSession RTCSession Call instance.
callReport Report Call quality report.
agreeChangeVideo (params: AgreeChangeVideoParamsType) => Promise<boolean> Whether to accept a switch to video call. If not specified, the system will reject by default.
status CallStatus Call status, including name, number, profile image, status of call mute, etc.
incomingList Session[] Incoming call array.
timer TimerType Call timer.
localStream MediaStream Local stream with video track only, no audio.
remoteStream MediaStream Remote stream with both audio and video tracks.

Method

Method Overview
Stop the call timer Hold a call Terminate a call
Listen for events Resume a call Renegotiate a call
Reject a call Send DTMF Switch audio to video
Answer a call Mute a call Switch video to audio
Hang up a call Unmute a call Update the call status
Perform a blind transfer Start recording Update the static properties of Session
Perform an attended transfer Pause recording Destroy Session instance
Stop the call timer
Method
stopTimer()
Parameters Null.
Return value
this
Listen for events
Method
on(eventName:string,listener: (...args: any[]) => void)
Parameters
  • eventName: The event name.
  • listener: Callback function.
Return value
this
Note: For more information about the events that you can listen for, see Events.
Reject a call
This method is equivalent to the 'Reject a call' method of PhoneOperator object.
Method
reject()
Parameters Null.
Return value
void
Answer a call
This method is equivalent to the 'Answer a call' method of PhoneOperator object.
Method
answer(option?: CallOptions, allowNoneCamera: boolean = true)
Parameters
  • option: Specify call options.
  • allowNoneCamera: Whether to allow answering without a camera.
Return value type
Promise<Result>
Hang up a call
This method is equivalent to the 'Hang up a call' method of PhoneOperator object.
Method
hangup() 
Parameters callId: The unique ID of each call.
Return value
void
Perform a blind transfer
This method is equivalent to the 'Perform a blind transfer' method of PhoneOperator object.
Method
blindTransfer(number: string) 
Parameters number: The number of the transfer target.
Return value
void
Perform an attended transfer
This method is equivalent to the 'Perform an attended transfer' method of PhoneOperator object.
Method
attendedTransfer(number: string) 
Parameters number: The number of the transfer target.
Return value
void
Hold a call
This method is equivalent to the 'Hold a call' method of PhoneOperator object.
Method
hold()
Parameters Null.
Return value
void
Resume a call
This method is equivalent to the 'Resume a call' method of PhoneOperator object.
Method
unhold()
Parameters Null.
Return value
void
Send DTMF
This method is equivalent to the 'Send DTMF' method of PhoneOperator object.
Method
dtmf(dtmf: string)
Parameters dtmf: String (0123456789*#)
Return value
void
Mute a call
This method is equivalent to the 'Mute a call' method of PhoneOperator object.
Method
mute()
Parameters Null.
Return value
void
Unmute a call
This method is equivalent to the 'Unmute a call' method of PhoneOperator object.
Method
unmute()
Parameters Null.
Return value
void
Start recording
This method is equivalent to the 'Start recording' method of PhoneOperator object.
Method
startRecord()
Parameters Null.
Return value
void
Pause recording
This method is equivalent to the 'Pause recording' method of PhoneOperator object.
Method
pauseRecord()
Parameters Null.
Return value
void
Terminate a call
This method is equivalent to the 'Terminate a call' method of PhoneOperator object.
Method
terminate(type: 'hangup' | 'reject' | 'terminate' = 'terminate')
Parameters type: Type of call termination.
Return value
void
Renegotiate a call
Method
renegotiate(offerToReceiveVideo?: boolean) 
Parameters offerToReceiveVideo: Whether to receive video.
Return value type boolean
Switch audio to video
Method
audioToVideo(allowNoneCamera: boolean = true) 
Parameters allowNoneCamera: Whether to allow calls without a camera.
Return value
Promise<Result>
Switch video to audio
Method
videoToAudio() 
Parameters Null
Return value boolean
Update the call status
Method
setStatus(status: Partial<CallStatus>)
Parameters status: The call status object.
Return value
this
Update the static properties of Session
Method
setStaticStatus(staticStatus: Partial<StaticCallStatus>, startManualModel?: boolean)
Parameters
  • 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
this
Destroy Session instance
This method will cancel all the event subscriptions, and stop the RTCSession.
Method
destroy()
Parameters Null.
Return value Null.

Events

Event Name Description Report Parameter
callReport The call quality report is updated, with a frequency of once every 3 seconds.
  • callId: string: The unique ID of the call.
  • callReport: Report: Call quality report.
streamAdded A media stream is added to the call.
  • callId: string: The unique ID of the call.
  • communicationType: "outbound" | "inbound": Call type.
  • stream: MediaStream: Media stream.
ended The call is ended.
  • callId: string: The unique ID of the call.
  • cause: string: Reason for ending the call.
failed Failed to make a call.
  • callId: string: The unique ID of the call.
  • cause: string: Reasons for the call failure.
  • code: number: Error code.
clientError Errors occurred on the client, resulting in the failure to make a call.
  • callId: string: The unique ID of the call.
  • cause: string: Reason for the error.
reinvite The other party performed attended transfer during a call.
  • callId: string: The unique ID of the call.
  • session: Session: The current call instance.
accepted Received the success status response code 200 OK.
  • callId: string: The unique ID of the call.
  • session: Session: The current call instance.
confirmed The session is confirmed (received the response of ACK packet).
  • callId: string: The unique ID of the call.
  • session: Session: The current call instance.
statusChange Call status is changed.
  • newStatus: New call status.
  • oldStatus: Previous call status.
staticStatusChange The static properties of the call is changed.
  • newStatus: New static properties.
  • oldStatus: Previous static properties.