new sip(onEvents, domElements, options)
SIP usecase
Parameters:
Name | Type | Description |
---|---|---|
onEvents |
object | Event handlers: onCalling, onIncomingCall, onAccepted, onHangUp, onLocalReady, onRemoteReady, onRegistered, onRegisteredFailed |
domElements |
object | DOM elements: local, remote |
options |
object | Available options: |
Returns:
SIP methods: closeUsecase, register, accept, hangup, decline, sendDtmf, call
- Type
- Promise
Example
var onEvents = { onRegistered: function(username) { // Registered }, onRegisteredFailed: function(code, reason) { // Registered failed }, onCalling: function() { // Calling }, onIncomingCall: function(username) { // Incoming Call }, onAccepted: function() { // Accepted }, onHangUp: function(code, reason) { // Hangup }, onLocalReady: function(stream) { // Local stream }, onRemoteReady: function(stream) { // Remote stream } }; var domElements = { local: document.getElementById('localVideo'), remote: document.getElementById('remoteVideo') }; var options = { stream: { aDeviceId: null } }; usecases.sip(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> accept()
-
Accept an incoming call
Returns:
- Type
- nothing
Example
action.accept();
-
<inner> call(uri, headers)
-
Make a Call
Parameters:
Name Type Description uri
string String URI
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