MjSip Stack
v1.6

org.zoolu.sip.provider
Class SipInterface

java.lang.Object
  |
  +--org.zoolu.sip.provider.SipInterface
All Implemented Interfaces:
SipProviderListener
Direct Known Subclasses:
SipPromisqueInterface

public class SipInterface
extends java.lang.Object
implements SipProviderListener

SipInterface is actually the SIP SAP (Service Access Point) and can be used to send and receive SIP messages associated with a specific method, transaction, or dialog.

SipInterface provides a simple interface to the multiplexing function provided by the SipProvider layer.
It simply wraps the SipProvider by adding and removing the listener for capturing received SIP messages.

When creating a new SipInterface the following parameters, have to be specified: - sip_provider is the SipProvider the SipInterface has to be bound to, - id is the SIP interface identifier the SipInterface has to be bound to, - listener is the SipInterfaceListener that received messages are passed to.

The SIP interface id specifies the type of messages the listener is going to receive for. Together with the sip_provider, it represents the complete SIP Service Access Point (SAP) address/identifier used for demultiplexing SIP messages at receiving side.

The identifier can be of one of the three following types: transaction_id, dialog_id, or method_id. These types of identifiers characterize respectively:
- messages within a specific transaction,
- messages within a specific dialog,
- messages related to a specific SIP method. It is also possible to use the the identifier ANY to specify
- all messages that are out of any transactions, dialogs, or already specified method types.

When receiving a message, the underling SipProvider first tries to look for a SipInterface associated to the corresponding transaction, then looks for a SipInterface associated to the corresponding dialog, then for a SipInterface associated to the corresponding method type, and finally for a SipInterface associated to ANY messages. If the present SipInterface id matches, the SipInterfaceListener method onReceivedMessage() is fired.


Constructor Summary
SipInterface(SipProvider sip_provider, Identifier id, SipInterfaceListener listener)
          Creates a new SipInterface.
SipInterface(SipProvider sip_provider, SipInterfaceListener listener)
          Creates a new SipInterface.
 
Method Summary
 void close()
          Close the SipInterface.
 SipProvider getSipProvider()
          Gets the SipProvider.
 void onReceivedMessage(SipProvider sip_provider, Message message)
          When a new Message is received by the SipProvider.
 ConnectionIdentifier sendMessage(Message msg)
          Sends the message msg.
 ConnectionIdentifier sendMessage(Message msg, ConnectionIdentifier conn_id)
          Sends the message msg using the specified connection.
 ConnectionIdentifier sendMessage(Message msg, java.lang.String proto, java.lang.String dest_addr, int dest_port, int ttl)
          Sends a Message, specifing the transport portocol, nexthop address and port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipInterface

public SipInterface(SipProvider sip_provider,
                    SipInterfaceListener listener)
Creates a new SipInterface.

SipInterface

public SipInterface(SipProvider sip_provider,
                    Identifier id,
                    SipInterfaceListener listener)
Creates a new SipInterface.
Method Detail

close

public void close()
Close the SipInterface.

getSipProvider

public SipProvider getSipProvider()
Gets the SipProvider.

sendMessage

public ConnectionIdentifier sendMessage(Message msg,
                                        java.lang.String proto,
                                        java.lang.String dest_addr,
                                        int dest_port,
                                        int ttl)
Sends a Message, specifing the transport portocol, nexthop address and port.

This is a low level method and forces the message to be routed to a specific nexthop address, port and transport, regardless whatever the Via, Route, or request-uri, address to.

In case of connection-oriented transport, the connection is selected as follows:
- if an existing connection is found matching the destination end point (socket), such connection is used, otherwise
- a new connection is established

Returns:
It returns a Connection in case of connection-oriented delivery (e.g. TCP) or null in case of connection-less delivery (e.g. UDP)

sendMessage

public ConnectionIdentifier sendMessage(Message msg)
Sends the message msg.

The destination for the request is computed as follows:
- if outbound_addr is set, outbound_addr and outbound_port are used, otherwise
- if message has Route header with lr option parameter (i.e. RFC3261 compliant), the first Route address is used, otherwise
- the request's Request-URI is considered.

The destination for the response is computed based on the sent-by parameter in the Via header field (RFC3261 compliant)

As transport it is used the protocol specified in the 'via' header field

In case of connection-oriented transport:
- if an already established connection is found matching the destination end point (socket), such connection is used, otherwise
- a new connection is established

Returns:
Returns a ConnectionIdentifier in case of connection-oriented delivery (e.g. TCP) or null in case of connection-less delivery (e.g. UDP)

sendMessage

public ConnectionIdentifier sendMessage(Message msg,
                                        ConnectionIdentifier conn_id)
Sends the message msg using the specified connection.

onReceivedMessage

public void onReceivedMessage(SipProvider sip_provider,
                              Message message)
When a new Message is received by the SipProvider.
Specified by:
onReceivedMessage in interface SipProviderListener

MjSip Stack
v1.6