Guides

Receive a Call

This guide uses the full SIP.js API. The Simple User is intended to help get beginners up and running quickly. This guide is adopted from the SIP.js Github API documentation.

Prerequisites

See the User Agent guide on how to create a user agent. This guide requires a registered user agent.

User Agent Delegate

When SIP.js receives a SIP INVITE from another endpoint, it is processeed by the UserAgent. A delegate can be attached to the user agent to receive the invitation. A UserAgentDelegate is used as the handle to get information out of the user agent.

function onInvite(invitation) {
  // Defined In Next Steps
}

const userAgentOptions: UserAgentOptions = {
  authorizationPassword: 'secretPassword',
  authorizationUsername: 'authorizationUsername',
  delegate: {
    onInvite
  }
  transportOptions,
  uri
};
const userAgent = new UserAgent(userAgentOptions);

onInvite()

When an INVITE is received the user agent will call the delegate’s onInvite(invitation) function. An invitation will be passed to the function so that the application can interact with the INVITE.

Accept

To accept the INVITE use the accept() function on the invitation.

function onInvite(invitation) {
  invitation.accept();
}

Reject

To reject the INVITE use the reject() function on the invitation.

function onInvite(invitation) {
  invitation.reject();
}