Class: 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
     },
     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


<inner> accept()

Accept an incoming call

Returns:
Type
nothing
Example
action.accept();

<inner> call(uri, headers)

Make a Call

Parameters:
Name Type Description
uri string

SIP URI to call

headers object

Custom SIP Headers (Optional)

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

<inner> closeUsecase()

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

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

<inner> decline()

Decline a call

Returns:
Type
nothing
Example
action.decline();

<inner> hangup()

Hangup a call

Returns:
Type
nothing
Example
action.hangup();

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

<inner> sendDtmf(dtmf)

Send a DTMF tone

Parameters:
Name Type Description
dtmf string

Digit

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

<inner> toggleAudio()

Toggle local Audio stream (Mute/Unmute)

Returns:

Is audio muted?

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