Usecase: sip

sip

SIP usecase


new sip(onEvents, domElements, options)

SIP usecase

Parameters:
Name Type Description
onEvents object

Event handlers: onEvents

domElements object

DOM elements: domElements

options object

Available options: options

Returns:

SIP actions

Type
Promise
Example
var onEvents = {
    onRegistered: username => {
         // Successfully registered
    },
    onRegisteredFailed: (code, reason) => {
         // Failed registered
    },
    onCalling: () => {
         // Calling a peer
    },
    onIncomingCall: username => {
         // Incoming call from a peer
    },
    onAccepted: () => {
         // Call accepted
    },
    onHangUp: (code, reason) => {
         // Hang up call
    },
    onLocalReady: stream => {
         // The local stream is ready
    },
    onRemoteReady: stream => {
         // The remote stream is ready
    }
};

var domElements = {
    local: document.getElementById('localVideo'),
    remote: document.getElementById('remoteVideo')
};

var options = {
     stream: {
         aDeviceId: null,
         vDeviceId: null
     },
     account: "******" // Multiple mode
};

usecases.sip(onEvents, domElements, options)
    .then(action => {
         // Use Case has been atacched succesfully
         ...
    })
    .catch(cause => {
        // Error attaching the Use Case
        console.log("Error Attach " + cause );
    })

Methods


accept()

Accept an incoming call

Returns:
Type
nothing
Example
action.accept();

call(uri, headers, video)

Make a Call

Parameters:
Name Type Description
uri string

SIP URI to call

headers object

Custom SIP Headers (Optional)

video boolean

Use video (Optional)

Example
action.call('sip:extension@domain:port', {"My-Header": "Value"});

closeUsecase()

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

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

decline()

Decline a call

Returns:
Type
nothing
Example
action.decline();

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);

hangup()

Hangup a call

Returns:
Type
nothing
Example
action.hangup();

register(userName, displayName, proxy, authUser, secret)

Register an Account

Parameters:
Name Type Description
userName string

UserName

displayName string

Display Name

proxy string

Proxy String

authUser string

Auth User (Optional)

secret string

Password (Optional)

Returns:
Type
nothing
Example
action.register('sip:1234@domain', 'Peter', 'sip:domain:port', 'agent', 's3cr3t');

replaceVideo(type)

Replace the local Video track

Parameters:
Name Type Description
type string

'video' or 'screen'

Example
action.replaceVideo('screen');

sendDtmf(dtmf)

Send a DTMF tone

Parameters:
Name Type Description
dtmf string

Digit

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

toggleAudio()

Toggle local Audio stream (Mute/Unmute)

Returns:

Is audio muted?

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

toggleVideo()

Toggle local Video stream (Mute/Unmute)

Returns:

Is video muted?

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