Skip to content
Branch: master
Find file History
james-criscuolo Merge pull request #726 from john-e-riordan/dev-master
New API - fix re-INVITE rejection handling
Latest commit f056d54 Aug 20, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
api Update documentation Aug 9, 2019
core Update documentation Aug 7, 2019
MIGRATION.md Update migration.md Aug 13, 2019
MOH.md Docs - root Jul 12, 2019
README.md New API Change Jul 29, 2019
TODO.md Update TODO Aug 7, 2019

README.md

Documentation

API Overview

Reference Documentation: API

The SIP application programming interface (API) herein is implemented on top of the Core Library.

The API is intended to provide a complete and suitable interface for most end user applications.

However, if an application requires protocol level access it may need to utilize the core library directly.

Example (TypeScript)

/*
 * Create a user agent
 */
const uri = UserAgent.makeURI("sip:alice@example.com");
if (!uri) {
  // Failed to create URI
}
const userAgentOptions: UserAgentOptions = {
  uri: uri,
  /* ... */
};
const userAgent = new UserAgent(userAgentOptions);

/*
 * Setup handling for incoming INVITE requests
 */
userAgent.delegate = {
  onInvite(invitation: Invitation): void {

    // An Invitation is a Session
    const incomingSession: Session = invitation;

    // Setup incoming session delegate
    incomingSession.delegate = {
      // Handle incoming REFER request.
      onRefer(referral: Referral): void {
        // ...
      }
    };

    // Handle incoming session state changes.
    incomingSession.stateChange.on((newState: SessionState) => {
      switch (newState) {
        case SessionState.Establishing:
          // Session is establishing.
          break;
        case SessionState.Established:
          // Session has been established.
          break;
        case SessionState.Terminated:
          // Session has terminated.
          break;
        default:
          break;
      }
    });
  }
};

/*
 * Start the user agent
 */
userAgent.start().then(() => {

  /*
   * Register the user agent
   */
  const registererOptions: RegistererOptions = { /* ... */ };
  const registerer = new Registerer(userAgent, registererOptions);
  registerer.register();

  /*
   * Send an outgoing INVITE request
   */
  const target = UserAgent.makeURI("sip:bob@example.com");
  if (!target) {
    throw new Error("Failed to create target URI.");
  }

  // Create a new Inviter
  const inviterOptions: InviterOptions = { /* ... */ };
  const inviter = new Inviter(userAgent, target, inviterOptions);

  // An Inviter is a Session
  const outgoingSession: Session = inviter;

  // Setup outgoing session delegate
  outgoingSession.delegate = {
    // Handle incoming REFER request.
    onRefer(referral: Referral): void {
      // ...
    }
  };

  // Handle outgoing session state changes.
  outgoingSession.stateChange.on((newState: SessionState) => {
    switch (newState) {
      case SessionState.Establishing:
        // Session is establishing.
        break;
      case SessionState.Established:
        // Session has been established.
        break;
      case SessionState.Terminated:
        // Session has terminated.
        break;
      default:
        break;
    }
  });

  // Send the INVITE request
  inviter.invite()
    .then(() => {
      // INVITE sent
    })
    .catch((error: Error) => {
      // INVITE did not send
    });

});

Core Library Overview

Reference Documentation: Core Library

Herein is an implementation of the core SIP protocol constructs.

The library is intended to provide an implemenation the RFC specification details usable as building blocks for a "higher level" interface.

In fact, most applications should find the "higher level" API which is built on top of this core library to be the optimial integration point.

Getting Started

Start by taking a look at UserAgentCore & UserAgentCoreDelegate which provide the highest level interfaces for sending and receiving SIP request messages and the main integration point (creating a new UserAgentCore is step one). Next take a look at Session & SessionDelegate which are products of a successful INVITE request and provide the interfaces for sending and receiving in dialog requests (BYE, for example) as well as for dealing with the offer/answer exchange.

Interfaces and Implementations

./dialogs

./messages

./transactions

./session

The Session interface represents a SIP Session and is the result of a successful INVITE request.

./subscription

The Subscription interface represents a SIP Subscription and is the result of a successful SUBSCRIBE request.

./timers

./transport

./user-agent-core

The UserAgentCore class provides the primary external interface with the SIP core.

./user-agents

You can’t perform that action at this time.