README
Ultron Client
Ultron Client is a typescript project based on Ultron API, providing a wrapped SDK to access webphone and rcv peer services.
Installation
put this dependency in your project package.json and execute
npm install
Getting started: Webphone
All services can be accessed with WebphoneSession instance, which can be constructed and initialized as below:
const webphoneRequest = {
type: 'webphone',
phoneNumber: '+182288888888',
password: 'xxxxxxx',
TTL: 1800000,
audioType: 'tone',
frequency: 440,
};
const session = new WebphoneSession(WEBPHONE_SERVER_HOST_URL, ENV_NAME, webphoneRequest);
await session.init();
A webphoneRequest includes following attributes:
- env: String, platform environment.
- phoneNumber: string, main phone number of RC account or PSTN
- extension: string, existing extension of phoneNumber, only for RC phone. Default 0.
- password: string, password of RC account.
- type: string, optional values: webphone, pstn, softphone. Default webphone.
- TTL: integer, session expiration in milliseconds. Default 600000.
- audioType: string, input media stream source type, optional values: microphone, audio, tone, dtmf. Default is microphone.
- frequency: number, if audioType is specified as tone, webphone session would play a tone with this frequency.
- sequence: string, if audioType is specified as dtmf, webphone session would play the specified dtmf sequence tone.
- audioURL: string, if audioType is specified as audio, webphone session would play the specified audio.
tips: You can specify optional settings like new WebphoneSession(WEBPHONE_SERVER_HOST_URL, ENV_NAME, webphoneRequest, { registerTimeout: 30, statusCheckTimeout: 30 })
Services
preOperate(action, always)
this function preset behavior when receiving an incoming call for given session.
- action: string, optional values are 'answerCall' and 'decline'.
- always: boolean, whether keep this presetting once or always, default false
makeCall(destNumber)
Make call from given session to destination phone number.
- destNumber: string, number representation can be a phone number, an extension or combination of them with separator #
answer()
Answer an incoming call
detect(type, duration, frequencies=[])
Detect audio within given duration by tone/dtmf detecting
hangup()
Hangup a call if given session is involved.
close()
Close a session.
Other allowed session actions:
- mute
- unmute
- hold
- unhold
- dtmf
- toVoiceMail
- startRecording
- stopRecording
Getting started: RCV Peer
All services can be accessed with RCVPeer instance, which can be constructed and initialized as below:
const PeerRequest = {
name: 'Peer#1',
user: {
phoneNumber: '+182288888888',
extension: '701',
password: 'xxxxxxx',
},
TTL: 30,
audioType: 'tone',
audioOption: { frequency: 440 },
videoType: 'fake',
videoOption: { screenRes: '960x540', pattern: true, text: true, qrCode: false},
detectable: true
};
const peer = new RCVPeer(WEBPHONE_SERVER_HOST_URL, ENV_NAME, PeerRequest);
await peer.init();
A PeerRequest includes following attributes:
- env: String, platform environment.
- user: object, optional, will be anonymous if no user provided.
- phoneNumber: string, main phone number of RC account or PSTN
- extension: string, existing extension of phoneNumber, only for RC phone. Default 0.
- password: string, password of RC account.
- audioType: string, optional values: tone, dtmf, audio, none. Default tone. none means no audio stream will be generated.
- audioOption: object, frequency value is required for tone audioType, sequence and repeat are required for dtmf audioType, file is required for audio audioType.
- videoType: string, optional values: fake, none. Default fake. none means no video stream will be generated.
- videoOption: object, screenRes is required, pattern, text and qrCode are elements that would appear in fake video.
- TTL: integer, session expiration in minutes. Default 30.
- detectable: boolean, if you need to detect audio or video in this peer for other participants, please set it to true.
tips: You can specify optional settings like new RCVPeer(WEBPHONE_SERVER_HOST_URL, ENV_NAME, PeerRequest, { registerTimeout: 30, statusCheckTimeout: 30 })
Services
joinMeeting(meetingId, notify=false)
Join a RCV meeting.
- meetingId: string, valid RCV meeting ID.
- notify: boolean, if this join operation needs to notify other devices.
leaveMeeting()
Leave current meeting.
close()
Remove a peer.
Other allowed peer actions:
- muteAudio
- unmuteAudio
- detectAudio
- detectVideo
- turnOnVideo
- turnOffVideo
- shareScreen
- unshareScreen