new splitClient(onEvents, domElements, options)
SplitClient usecase
Parameters:
Name | Type | Description |
---|---|---|
onEvents |
object | Event handlers: onEvents |
domElements |
object | DOM elements: domElements |
options |
object | Available options: options |
Returns:
SplitClient actions
- Type
- Promise
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
var onEvents = {
onCalling: () => {
// Calling a peer
},
onRegisteredFailed: cause => {
// Failed registered
console.log(cause);
},
onHangup: (code, cause) => {
// Hang up call
},
onAcceptedAudio: (data, stream) => {
// Accepted Audio by the remote peer
console.log(data.userName);
console.log(data.sessionId);
},
onReadyLocalAudio: () => {
// The local audio is ready
},
onReadyLocalStream: isVideo => {
// The local video is ready
console.log("Video is ready: " + isVideo);
},
onAcceptedVideo: stream => {
// Accepted Video by remote peer
},
onAcceptedData: () => {
// Accepted Data by remote peer
},
onDataReceived: (type, data, filename) => {
// Data received by the datachannel
if(type === 'application/x-chat') { }
else if(type === 'text/plain') { }
else if(type === 'application/pdf') { }
else if(type === 'application/zip') { }
else if(type === 'application/x-rar') { }
else if(type === 'image/jpeg') {}
else if(type === 'image/png') {}
else if(type === 'application/x-docx') {}
else if(type === 'application/x-pptx') {}
else if(type === 'application/x-xlsx') {}
else if(type === 'application/vnd.oasis.opendocument.text') {}
},
onStartRecording: () => {
// Start recording
},
onStopRecording: () => {
// Stop recording
},
onScreensharingAccepted: () => {
// ScreenSharing Accepted
},
onScreensharingClosed: () => {
// ScreenSharing Closed
},
onJoined: () => {
// You've joined the SPLIT session
},
onFileTransferOk: fileId => {
// File Transfer OK
},
onFileTransferKo: fileId => {
// File Transfer KO
},
onNotified: (action, data) => {
// Notification received from the remote peer
},
onVideoClosed: () => {
// Remote video is closed
}
};
var domElements = {
local: document.getElementById('localvideo'),
remote: document.getElementById('remotevideo'),
screenRemote: document.getElementById('remotescreen'),
screenLocal: document.getElementById('localscreen')
};
var options = {
dataChannel: {
dataEnabled: true,
allowedTypes: ['application/x-chat', 'image/jpeg', 'image/png', 'application/pdf'],
maxSize: 5, // In MB
fileTransmission: {
timeout: 5, // Minutes
retransmissionDelay: 15 // Seconds
}
},
stream: {
audioEnabled: true,
videoEnabled: true,
aDeviceId: null,
vDeviceId: null,
audioStream: null,
videoStream: null
},
account: "******" // Multiple mode
};
usecases.splitClient(onEvents, domElements, options)
.then(action => {
// Use Case has been atacched succesfully
...
})
.catch(cause => {
// Error attaching the Use Case
console.log("Error Attach " + cause );
})
Methods
-
<inner> call(callerId, videoRate, screenRate, headers, uri)
-
Client sends a request to start a call to an Agent
Parameters:
Name Type Description callerId
string Caller ID
videoRate
integer Video Bitrate (bps) (Optional)
screenRate
integer Screen Bitrate (bps) (Optional)
headers
object Custom SIP Headers (Optional)
uri
object SIP URI to call (Optional. default: sip:videortc@localhost:5099)
Returns:
- Type
- nothing
Example
1
action.call('IVRPowers', 128000, 256000, {"My-Header": "Value"}, "sip:videortc@localhost:5099");
-
<inner> closeUsecase()
-
Close the current UseCase. It's recommended combine with disconnect method
Returns:
- Type
- nothing
Example
-
<inner> getLicense()
-
The VideoGateway is requested about the features of the contracted license
Returns:
License Information (ScreenSharing, LiveChat and VideoRecording )
- Type
- Object
Example
-
<inner> hangup()
-
Client sends a request to hangup the call
Returns:
- Type
- nothing
Example
1
action.hangup();
-
<inner> notify(action, data)
-
Send a notification to the other peer via the VideoGateway
Parameters:
Name Type Description action
string Identifies the notification type
data
string Useful for sending extra data (Optional)
Example
1
action.notify('open-map', 'data');
-
<inner> sendData(type, data, cOk, cKo, filename)
-
Sends a message (Chat or File) through the DataChannel
Parameters:
Name Type Description type
string MIME Type (e.g: 'application/x-chat', 'text/plain', 'application/pdf', 'application/zip', 'application/x-rar', 'image/jpeg', 'image/png', 'application/x-docx', 'application/x-pptx', 'application/x-xlsx', 'application/vnd.oasis.opendocument.text')
data
string Data Content
cOk
function Callback success function
cKo
function Callback failed function
filename
string File Name (e.g: file.zip) (Optional)
Returns:
- Type
- nothing
Example
-
<inner> sendDtmf(dtmf)
-
Send a DTMF tone
Parameters:
Name Type Description dtmf
string Digit
Returns:
- Type
- nothing
Example
1
action.sendDtmf("5"); // Also "*" and "#"
-
<inner> setMode(video, data)
-
Modifies the audio/video mode of the local peer while the call is established.
Parameters:
Name Type Description video
boolean Enable Video?
data
boolean Enable Data?
Example
1
action.setMode(true, true);
-
<inner> startScreensharing(id, cOk, cKo)
-
The Client sends a request to start Screensharing
Parameters:
Name Type Description id
integer Screen Id (Deprecated - Any value sent in this parameter will be ignored)
cOk
function Callback Ok
cKo
function Callback Error
Returns:
- Type
- nothing
Example
-
<inner> stopScreensharing(cOk, cKo)
-
The Client sends a request to stop Screensharing
Parameters:
Name Type Description cOk
function Callback Ok
cKo
function Callback Error
Returns:
- Type
- nothing
Example
-
<inner> toggleAudio()
-
Toggle local Audio stream (Mute/Unmute)
Returns:
Is audio muted?
- Type
- boolean
Example
1
action.toggleAudio(); // true or false
-
<inner> toggleAudioRemote()
-
Toggle remote Audio stream (Mute/Unmute)
Returns:
Is audio muted?
- Type
- boolean
Example
1
action.toggleAudioRemote(); // true or false
-
<inner> toggleVideo()
-
Toggle local Video stream (Mute/Unmute)
Returns:
Is video muted?
- Type
- boolean
Example
1
action.toggleVideo(); // true or false