Getting Started

JsSIP User Agent is the core element in JsSIP. It represents the SIP client associated to a SIP account. JsSIP User Agent is defined in JsSIP.UA class.

Multiple JsSIP User Agents can be created (this is useful for having different SIP accounts running in the same web application).

Creating a JsSIP User Agent

User Agent Configuration

JsSIP User Agent requires a configuration object for its initialization. There are some mandatory configuration parameters and many optional ones. Check the full configuration parameters list.

var configuration = {
  'outbound_proxy_set': 'ws://sip-ws.example.com',
  'uri':                'sip:alice@example.com',
  'password':           'superpassword'
};

User Agent instance

var coolPhone = new JsSIP.UA(configuration);

User Agent events definition

Full list of User Agent events.

WebSocket connection events

coolPhone.on('connected', function(e){
  // Your code here
});

coolPhone.on('disconnected', function(e){
  // Your code here
});

Call reception event

coolPhone.on('newSession', function(e){
  // Your code here
});

IM message reception event

coolPhone.on('newMessage', function(e){
  // Your code here
});

SIP registration events

coolPhone.on('registered', function(e){
  // Your code here
});
coolPhone.on('unregistered', function(e){
  // Your code here
});
coolPhone.on('registrationFailed', function(e){
  // Your code here
});

Starting the User Agent

See JsSIP.UA.start() method definition.

coolPhone.start();

Making outbound calls

See JsSIP.UA.call() method definition.

// Use audio and video
var useAudio = true;
var useVideo = true;

var views = {
  'selfView':   document.getElementById('my-video'),
  'remoteView': document.getElementById('peer-video')
};

var eventHandlers = {
  'connecting': function(e){ // Your code here },
  'progress':   function(e){ // Your code here },
  'failed':     function(e){ // Your code here },
  'started':    function(e){ // Your code here },
  'ended':      function(e){ // Your code here }
};

coolPhone.call('sip:bob@example.com', useAudio, useVideo, eventHandlers, views);

Instant messaging

See JsSIP.UA.sendMessage() method definition.

// Use text/plain content type
var contentType = "text/plain";

var text = 'Hello Bob!';

var eventHandlers = {
  'succeeded': function(e){ // Your code here },
  'failed':    function(e){ // Your code here };
};

coolPhone.sendMessage('sip:bob@example.com', text, contentType, eventHandlers);