Class: splitClient

splitClient

SplitClient Use Case


new splitClient(onEvents, domElements, options)

A SplitClient Usecase is started

Parameters:
Name Type Description
onEvents object

Event handlers: onCalling, onRegisteredFailed, onHangup, onAcceptedAudio, onReadyLocalStream, onAcceptedVideo, onDataReceived, onStartRecording, onStopRecording, onScreensharingAccepted

domElements object

DOM elements: local, remote, screenRemote

options object

Available options: dataChannel, stream

Source:
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);
    },
    onReadyLocalStream: function() {
         // Ready Local Stream
    },
    onAcceptedVideo: function(stream) {
         // Accepted Video
    },
    onDataReceived: function(type, data, filename) {
        // Data received
        if(type === 'application/x-chat') { }
        if(type === 'text/plain') { }
        if(type === 'application/pdf') { }
        if(type === 'application/zip') { }
        if(type === 'application/x-rar') { }
        if(type === 'image/jpeg') {}
        if(type === 'image/png') {}
        if(type === 'application/x-docx') {}
        if(type === 'application/x-pptx') {}
        if(type === 'application/x-xlsx') {}
        if(type === 'application/vnd.oasis.opendocument.text') {}
    },
    onStartRecording: function() {
         // Start recording
    },
    onStopRecording: function() {
         // Stop recording
    },
    onScreensharingAccepted: function() {
         // ScreenSharing Accepted
    }
};

var domElements = {
    local: document.getElementById('localvideo'),
    remote: document.getElementById('remotevideo'),
    screenRemote: document.getElementById('remotescreen') // (Optional)
};

var options = {
     dataChannel: {
         dataEnabled: true,
         allowedTypes: ['application/x-chat', 'image/jpeg', 'image/png', 'application/pdf'],
         maxSize: 5 // In MB
     },
     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
callerId string

Caller ID

videoRate integer

Video Bitrate (kbps) (optional)

screenRate integer

Screen Bitrate (kbps) (optional)

Source:
Returns:
Type
nothing
Example
action.call('IVRPowers', 128000, 256000);

<inner> closeUsecase()

Close the current UseCase. It's recommended combine with disconnect method

Source:
Returns:
Type
nothing
Example
action.closeUsecase();
myVideoApp.disconnect(); // Recommended

<inner> getLicense()

The VideoGateway is requested about the features of the contracted license

Source:
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

Source:
Returns:
Type
nothing
Example
action.hangup();

<inner> sendData(type, data, cOk, cKo, (Optional))

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

(Optional) string

filename File Name (e.g: file.zip)

Source:
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
dtmf string

Digit

Source:
Returns:
Type
nothing
Example
action.sendDtmf("5"); // Also "*" and "#"

<inner> toggleAudio()

Toggle local Audio stream (Mute/Unmute)

Source:
Returns:

Is audio muted?

Type
boolean
Example
action.toggleAudio(); // true or false

<inner> toggleVideo()

Toggle local Video stream (Mute/Unmute)

Source:
Returns:

Is video muted?

Type
boolean
Example
action.toggleVideo(); // true or false