Version

SIPProvider

The SipProvider in the JAIN SIP API is designed to send and receive messages in the digital world of SIP communications, which includes making phone calls over the internet, video conferencing, and instant messaging.

Responsibilities of the SIPProvider class
Sending and Receiving SIP Messages: It's the main touchpoint for applications to interact with the SIP network, handling outgoing requests (like starting a call) and incoming messages (like receiving a call).
Managing Communications: Beyond just passing messages back and forth, it also deals with the more complex parts of a conversation, like making sure messages are delivered correctly and managing the lifecycle of a call or message exchange.

How Does It Work?

1. Connecting with Listeners:

Just as you might listen for your name to be called after placing an order, SipProvider allows applications to "listen" for incoming messages or notifications about the status of their communications. This is done through something called a SipListener.
Example: When a call comes in, the SipProvider alerts the SipListener that there's an incoming request.

sipProvider.addSipListener(new SipListener() {
    @Override
    public void processRequest(RequestEvent requestEvent) {
        // Handle incoming call request
    }
});

 

2. Sending Messages:

  • Whether it's starting a call or ending one, SipProvider can send messages out into the SIP network.
  • Statelessly Sending Requests: This means sending out a request without keeping track of it afterwards, useful for simple notifications or pings.

Request message = messageFactory.createRequest(...); // Create your SIP request here
sipProvider.sendRequest(message); // Send it off into the network

3. Transactions and Dialogs:
Communications in SIP can be complex, involving multiple steps back and forth. SipProvider manages these through "transactions" and "dialogs", keeping track of each step in a conversation.
Example: Confirming a call has been set up and maintaining that call.

sipProvider.addSipListener(new SipListener() {
    @Override
    public void processResponse(ResponseEvent responseEvent) {
        Response response = responseEvent.getResponse();
        int statusCode = response.getStatusCode();
        
        
        // Check if the response is successful (e.g., 200 OK)
        if (statusCode == 200) {
            // Access the dialog associated with this transaction
            Dialog dialog = responseEvent.getDialog();
            
            // Confirming the call setup within the dialog
            System.out.println("Call confirmed with dialog ID: " + dialog.getDialogId());
        }
    }
});

4. Listening Points:
These are essentially the "addresses" from which SipProvider sends requests and receives messages. You can have different listening points for different types of networks (like TCP or UDP).

For example, having one address for sending messages over WiFi and another for cellular data.

Key Methods

  • sendRequest(Request request): This method lets your application send out a call request, like dialing a number, without worrying about the call's ongoing management.

sipProvider.sendRequest(request); // 'request' is your SIP request

  • sendResponse(Response response): Similarly, this method is for sending a response, like answering a call, in a simple, "stateless" way.

sipProvider.sendResponse(response); // 'response' is your SIP response

  • addSipListener(SipListener listener): Registers a listener to receive events, making sure your application is alerted to incoming calls or messages.

sipProvider.addSipListener(new SipListener() {
    @Override
    public void processRequest(RequestEvent requestEvent) {
        // Handle incoming request
    }
});

The SipProvider is essential because it offers a standardized way to handle SIP communications, making it easier for developers to build apps that can make calls, send messages, or start video chats without getting bogged down in the complexities of the underlying SIP protocols.

Start innovating with Mobius

What's next? Let's talk!

Mobius Software

As a company you'll get:

  • Get started quickly

  • Support any business model

  • Join millions of businesses

Questions? websupport@mobius.com