org.cafesip.jiplet.sip
Class SipCommunicator

java.lang.Object
  extended by org.cafesip.jiplet.sip.SipCommunicator

public class SipCommunicator
extends java.lang.Object

This class enables SIP-related operations from within a jiplet class. It has methods to proxy requests, proxy responses and handle proxy timeouts. In addition, it can cancel proxy requests and other operations.


Constructor Summary
SipCommunicator(Jiplet jiplet, javax.sip.RequestEvent request)
          A constructor for this class.
SipCommunicator(Jiplet jiplet, javax.sip.ResponseEvent response)
           
SipCommunicator(Jiplet jiplet, javax.sip.TimeoutEvent timeout)
           
 
Method Summary
 void cancelRequest()
          This method is similar to the cancelRequest(int statusCode) method except that no response is sent to the originating request.
 void cancelRequest(int statusCode, java.lang.String reason)
          Cancels a proxy request.
 boolean dropOutboundLeg(javax.sip.ClientTransaction clientTransaction)
          Call this method to drop an outbound leg for the case where other outbound legs may be present and the event on this leg shouldn't drop everything.
 javax.sip.RequestEvent getRequest()
           
 javax.sip.ResponseEvent getResponse()
           
 javax.sip.ServerTransaction getServerTransaction()
           
 javax.sip.header.ContactHeader getStackContactHeader()
           
 javax.sip.header.ViaHeader getStackViaHeader()
           
 javax.sip.TimeoutEvent getTimeout()
           
 void handleProxyTimeout(boolean stateful)
          This method is used to handle proxy processing when a SIP timeout-occurs.
protected  boolean isReset()
           
 void proxyRequest(java.util.ArrayList uris, boolean addRecordRoute, boolean stateful, boolean presenceServer)
          This method is used to proxy a received SIP request message.
 void proxyRequest(javax.sip.address.URI uri, boolean addRecordRoute, boolean stateful, boolean presenceServer)
          This method is used to proxy a received SIP request message.
 void proxyResponse(boolean presenceServer)
          This method is used to proxy the received SIP response message.
protected  void setReset(boolean reset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipCommunicator

public SipCommunicator(Jiplet jiplet,
                       javax.sip.RequestEvent request)
A constructor for this class.


SipCommunicator

public SipCommunicator(Jiplet jiplet,
                       javax.sip.ResponseEvent response)

SipCommunicator

public SipCommunicator(Jiplet jiplet,
                       javax.sip.TimeoutEvent timeout)
Method Detail

cancelRequest

public void cancelRequest(int statusCode,
                          java.lang.String reason)
Cancels a proxy request. For this to work, the proxy object must be obtained by calling the method requestEvent.getProxy() from the processRequest() method of the jiplet class (or a class that extends jiplet). If stateless, this method does nothing. Otherwise, it cancels the previous operation by sending a CANCEL request to all the dialogs (call legs). If the parameter statusCode is greater than 0, it also sends a response with the provided status code to the leg that sent the original request.

Parameters:
statusCode - A value greater than zero will result in a response to the user agent that started the dialog. If this is not desired, use -1 as this parameter.
reason - A reason phrase along with the status code. If null, the reason phrase is not added.

cancelRequest

public void cancelRequest()
This method is similar to the cancelRequest(int statusCode) method except that no response is sent to the originating request.


dropOutboundLeg

public boolean dropOutboundLeg(javax.sip.ClientTransaction clientTransaction)
Call this method to drop an outbound leg for the case where other outbound legs may be present and the event on this leg shouldn't drop everything.

Parameters:
clientTransaction - for this leg
Returns:
true if this leg was dropped, false otherwise

proxyRequest

public void proxyRequest(java.util.ArrayList uris,
                         boolean addRecordRoute,
                         boolean stateful,
                         boolean presenceServer)
                  throws javax.sip.InvalidArgumentException,
                         JipletException,
                         java.text.ParseException,
                         javax.sip.SipException
This method is used to proxy a received SIP request message.

Parameters:
uris - list of URIs to proxy a SIP request message to. For ACK, CANCEL and BYE messages for a stateful proxy, the contact list can be an empty array list. The proxy will automatically proxy the request based on the dialog
addRecordRoute - true if record route is to be added.
true - if stateful proxy is required.
true - if the proxy server is a presence server
Throws:
javax.sip.SipException
java.text.ParseException
JipletException
javax.sip.InvalidArgumentException

getStackViaHeader

public javax.sip.header.ViaHeader getStackViaHeader()
                                             throws java.text.ParseException,
                                                    javax.sip.InvalidArgumentException
Throws:
java.text.ParseException
javax.sip.InvalidArgumentException

getStackContactHeader

public javax.sip.header.ContactHeader getStackContactHeader()
                                                     throws java.text.ParseException
Throws:
java.text.ParseException

proxyRequest

public void proxyRequest(javax.sip.address.URI uri,
                         boolean addRecordRoute,
                         boolean stateful,
                         boolean presenceServer)
                  throws javax.sip.InvalidArgumentException,
                         JipletException,
                         java.text.ParseException,
                         javax.sip.SipException
This method is used to proxy a received SIP request message. This method is similar to the other proxyRequest method except that it proxies the request to a single location.

Throws:
javax.sip.InvalidArgumentException
JipletException
java.text.ParseException
javax.sip.SipException

proxyResponse

public void proxyResponse(boolean presenceServer)
                   throws JipletException,
                          javax.sip.SipException,
                          java.text.ParseException
This method is used to proxy the received SIP response message.

Parameters:
true - if the proxy server is a presence server
Throws:
JipletException
java.text.ParseException
javax.sip.SipException

handleProxyTimeout

public void handleProxyTimeout(boolean stateful)
                        throws java.text.ParseException,
                               javax.sip.SipException,
                               JipletException
This method is used to handle proxy processing when a SIP timeout-occurs. The jiplet is notified of timeout by the container by invoking the processTimeout() method. The jiplet should call this method for handling the timeout-related to proxy forwarding.

Parameters:
stateful - true if the proxy is stateful
Throws:
java.text.ParseException
javax.sip.SipException
JipletException

getServerTransaction

public javax.sip.ServerTransaction getServerTransaction()
Returns:
the server transaction. Must be called after a proxyRequest() or a proxyResponse() has been called.

isReset

protected boolean isReset()

setReset

protected void setReset(boolean reset)

getRequest

public javax.sip.RequestEvent getRequest()
Returns:
returns the request event.

getResponse

public javax.sip.ResponseEvent getResponse()
Returns:
returns the response event

getTimeout

public javax.sip.TimeoutEvent getTimeout()
Returns:
the timeout event


http://www.cafesip.org