new splitClient(onEvents, domElements, options)
SplitClient usecase
Parameters:
| Name | Type | Description | 
|---|---|---|
onEvents | 
            
            object | Event handlers: onCalling, onRegisteredFailed, onHangup, onReadyLocalAudio, onReadyLocalStream, onAcceptedAudio, onAcceptedVideo, onAcceptedData, onDataReceived, onStartRecording, onStopRecording, onScreensharingAccepted, onScreensharingClosed, onFileTransferOk, onFileTransferKo, onJoined, onNotified, onVideoClosed  | 
        
domElements | 
            
            object | DOM elements: local, remote, screenRemote, screenLocal  | 
        
options | 
            
            object | Available options: dataChannel, stream  | 
        
Returns:
SplitClient methods: call, getLicense, hangup, sendData, sendDtmf, toggleAudio, toggleVideo
- Type
 - Promise
 
Example
var onEvents = {
    onCalling: function() {
         // Calling
    },
    onRegisteredFailed: function(cause) {
         // Register failed
         console.log(cause);
    },
    onHangup: function(code, cause) {
         // HangUp
    },
    onAcceptedAudio: function(data, stream) {
         // Accepted Audio
         console.log(data.userName);
         console.log(data.sessionId);
    },
    onReadyLocalAudio: function() {
         // Ready Local Audio
    },
    onReadyLocalStream: function(isVideo) {
         // Ready Local Stream
         console.log("Video is ready: " + isVideo);
    },
    onAcceptedVideo: function(stream) {
         // Accepted Video
    },
    onAcceptedData: function() {
         // Accepted Data
    },
    onDataReceived: function(type, data, filename) {
        // Data received
        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: function() {
         // Start recording
    },
    onStopRecording: function() {
         // Stop recording
    },
    onScreensharingAccepted: function() {
         // ScreenSharing Accepted
    },
    onScreensharingClosed: function() {
         // ScreenSharing Closed
    },
    onJoined: function(screenRoom) {
         // Joined
    },
    onFileTransferOk: function(fileId) {
         // File Transfer OK
    },
    onFileTransferKo: function(fileId) {
         // File Transfer KO
    },
    onNotified: function(action, data) {
         // Notification
    },
    onVideoClosed: function() {
    }
};
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,
         recordPrefix: '__default__'
     }
};
usecases.splitClient(onEvents, domElements, options)
    .then(function(action) {
         // Use Case has been atacched succesfully
         ...
    })
    .catch(function(cause) {
        // Error attaching the Use Case
        console.log("Error Attach " + cause );
    })
    
Methods
- 
    
<inner> call(callerId, videoRate, screenRate)
 - 
    
    
Client sends a request to start a call to an Agent
Parameters:
Name Type Description callerIdstring Caller ID
videoRateinteger Video Bitrate (bps) (Optional)
screenRateinteger Screen Bitrate (bps) (Optional)
Returns:
- Type
 - nothing
 
Example
action.call('IVRPowers', 128000, 256000); - 
    
<inner> closeUsecase()
 - 
    
    
Close the current UseCase. It's recommended combine with disconnect method
Returns:
- Type
 - nothing
 
Example
action.closeUsecase(); myVideoApp.disconnect(); // Recommended
 - 
    
<inner> getLicense()
 - 
    
    
The VideoGateway is requested about the features of the contracted license
Returns:
License Information (Screensharing, Livechat and VideoRecording )
- Type
 - Object
 
Example
var myLicense = action.getLicense(); console.log(myLicense);
 - 
    
<inner> hangup()
 - 
    
    
Client sends a request to hangup the call
Returns:
- Type
 - nothing
 
Example
action.hangup();
 - 
    
<inner> notify(action, data)
 - 
    
    
Send a notification to the other peer via the VideoGateway
Parameters:
Name Type Description actionstring Identifies the notification type
datastring Useful for sending extra data (Optional)
Example
action.notify('open-map'); - 
    
<inner> sendData(type, data, cOk, cKo, filename)
 - 
    
    
Sends a message (Chat or File) through the DataChannel
Parameters:
Name Type Description typestring 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')
datastring Data Content
cOkfunction Callback success function
cKofunction Callback failed function
filenamestring File Name (e.g: file.zip) (Optional)
Returns:
- Type
 - nothing
 
Example
action.sendData('application/x-chat', 'Hello Mike!', function(cOk) { // Success }, function(error) { // Error console.log(error); } ) - 
    
<inner> sendDtmf(dtmf)
 - 
    
    
Send a DTMF tone
Parameters:
Name Type Description dtmfstring Digit
Returns:
- Type
 - nothing
 
Example
action.sendDtmf("5"); // Also "*" and "#" - 
    
<inner> startScreensharing(screenId, cOk, cKo)
 - 
    
    
The Client sends a request to start Screensharing
Parameters:
Name Type Description screenIdinteger Screen Id
cOkfunction Callback Ok
cKofunction Callback Error
Returns:
- Type
 - nothing
 
Example
action.startScreensharing(1234, function() { // Success }, function(cause) { // Error }) - 
    
<inner> stopScreensharing(cOk, cKo)
 - 
    
    
The Client sends a request to stop Screensharing
Parameters:
Name Type Description cOkfunction Callback Ok
cKofunction Callback Error
Returns:
- Type
 - nothing
 
Example
action.stopScreensharing(function() { // Success }, function(cause) { // Error }) - 
    
<inner> toggleAudio()
 - 
    
    
Toggle local Audio stream (Mute/Unmute)
Returns:
Is audio muted?
- Type
 - boolean
 
Example
action.toggleAudio(); // true or false
 - 
    
<inner> toggleVideo()
 - 
    
    
Toggle local Video stream (Mute/Unmute)
Returns:
Is video muted?
- Type
 - boolean
 
Example
action.toggleVideo(); // true or false