public interface ProxyExt
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.sip.Proxy;
import javax.servlet.sip.ProxyBranch;
import javax.servlet.sip.SipFactory;
import javax.servlet.sip.SipServlet;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.URI;
import org.mobicents.javax.servlet.sip.ProxyBranchListener;
import org.mobicents.javax.servlet.sip.ProxyExt;
import org.mobicents.javax.servlet.sip.ResponseType;
public class ProxySipServlet extends SipServlet implements ProxyBranchListener {
protected void doInvite(SipServletRequest request) throws ServletException,
IOException {
if(!request.isInitial()){
return;
}
SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
Proxy proxy = request.getProxy();
proxy.setParallel(false);
// set the timeout for receiving a final response
proxy.setProxyTimeout(5);
// set the timeout for receiving a 1xx response
((ProxyExt)proxy).setProxy1xxTimeout(1);
proxy.setRecordRoute(true);
ArrayList uris = new ArrayList();
URI uri1 = sipFactory.createAddress("sip:receiver@127.0.0.1:5057").getURI();
URI uri2 = sipFactory.createAddress("sip:second-receiver@127.0.0.1:5056").getURI();
uris.add(uri2);
uris.add(uri1);
proxy.proxyTo(uris);
}
/**
* Called if no 1xx and no final response has been received with a response type of INFORMATIONAL
* Called if no 2xx response has been received with a response type of FINAL
*\/
public void onProxyBranchResponseTimeout(ResponseType responseType,
ProxyBranch proxyBranch) {
logger.info("onProxyBranchResponseTimeout callback was called. responseType = " + responseType + " , branch = " + proxyBranch + ", request " + proxyBranch.getRequest() + ", response " + proxyBranch.getResponse());
}
| Modifier and Type | Method and Description |
|---|---|
int |
getProxy1xxTimeout()
The current value of the overall proxy 1xx timeout value.
|
boolean |
getSipOutboundSupport()
Returns true if this proxy object is set to support the RFC 5626 Sip Outbound or false otherwise.
|
void |
setOutboundInterface(SipURI outboundInterface)
In multi-homed environment this method can be used to select the outbound interface and port number and transport to use for proxy branches.
|
void |
setProxy1xxTimeout(int timeout)
This is the amount of time, in seconds, the container waits for an informational response when proxying.
If the proxy is sequential, when the timer expires and no 1xx response nor final response has been received,
the container CANCELs the current branch and proxies to the next element in the target set.
|
void |
setRecordRouteURI(SipURI uri)
Allow setting/modifying RecordRoute Header on a SipServletRequest to allow interoperability with Lync.
|
void |
setSipOutboundSupport(boolean sipOutboundSupport)
Specifies whether this proxy object is set to support the RFC 5626 Sip Outbound or not.
|
void |
storeTerminationInformation(boolean store)
Enable (or disable) the storing of routing information required to terminate a proxy using terminateSession.
|
void |
terminateSession(SipSession session,
int calleeResponseCode,
String calleeResponseText,
int callerResponseCode,
String callerResponseText)
Terminates an established session by sending BYE requests in both directions.
|
void setProxy1xxTimeout(int timeout)
timeout - new search 1xx timeout in secondsIllegalArgumentException - if the container cannot set the value as requested because it is too high, too low or negativeint getProxy1xxTimeout()
void setOutboundInterface(SipURI outboundInterface)
outboundInterface - the sip uri representing the outbound interface to use when forwarding requests with this proxyNullPointerException - on null sip uriIllegalArgumentException - if the sip uri is not understood by the container as one of its outbound interfacevoid storeTerminationInformation(boolean store)
throws IllegalStateException
store - true to store information for termination, false to return to default behaviourIllegalStateException - if the proxy session has been establishedvoid setSipOutboundSupport(boolean sipOutboundSupport)
sipOutboundSupport - whether this proxy object is set to support the RFC 5626 Sip Outbound or notboolean getSipOutboundSupport()
void terminateSession(SipSession session, int calleeResponseCode, String calleeResponseText, int callerResponseCode, String callerResponseText) throws IllegalStateException, IOException
session - The SipSession to terminatecalleeResponseCode - SIP response code to include in a Reason header in BYE sent to original call recipient. Must be in the range 300-699.calleeResponseText - SIP response text to include in BYE sent to original call recipient. If null, no reason header will be used.callerResponseCode - SIP response code to include in a Reason header in BYE sent to original caller. Must be in the range 300-699.callerResponseText - SIP response text to include in BYE sent to original caller. If null, no reason header will be used.IllegalStateException - if the proxy session is not yet established or storeTerminationInformation not called before session was established.IOException - if a transport error occurs when trying to send this requestvoid setRecordRouteURI(SipURI uri)
https://github.com/Mobicents/sip-servlets/issues/63Copyright © 2015. All Rights Reserved.