private boolean loopDetectedSeen;
public void processRequest(RequestEvent requestEvent) {
try {
Request request = requestEvent.getRequest();
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
this.inviteServerTxProvider = sipProvider;
if (request.getMethod().equals(Request.INVITE)) {
ListeningPoint lp = sipProvider.getListeningPoint(protocolObjects.transport);
String host = lp.getIPAddress();
int port = lp.getPort();
ServerTransaction st = null;
if (requestEvent.getServerTransaction() == null) {
st = sipProvider.getNewServerTransaction(request);
Request newRequest = (Request) request.clone();
SipURI sipUri = protocolObjects.addressFactory.createSipURI("UA1",
"127.0.0.1");
sipUri.setPort(5080);
sipUri.setLrParam();
Address address = protocolObjects.addressFactory.createAddress("client1",
sipUri);
RouteHeader rheader = protocolObjects.headerFactory
.createRouteHeader(address);
newRequest.addFirst(rheader);
ViaHeader viaHeader = protocolObjects.headerFactory.createViaHeader(host,
port, protocolObjects.transport, null);
newRequest.addFirst(viaHeader);
ClientTransaction ct1 = sipProvider.getNewClientTransaction(newRequest);
sipUri = protocolObjects.addressFactory.createSipURI("proxy", "127.0.0.1");
address = protocolObjects.addressFactory.createAddress("proxy", sipUri);
sipUri.setPort(5080);
sipUri.setLrParam();
RecordRouteHeader recordRoute = protocolObjects.headerFactory
.createRecordRouteHeader(address);
newRequest.addHeader(recordRoute);
ct1.setApplicationData(st);
this.clientTxTable.add(ct1);
newRequest = (Request) request.clone();
sipUri = protocolObjects.addressFactory.createSipURI("UA2", "127.0.0.1");
sipUri.setLrParam();
sipUri.setPort(5080);
address = protocolObjects.addressFactory.createAddress("client2", sipUri);
rheader = protocolObjects.headerFactory.createRouteHeader(address);
newRequest.addFirst(rheader);
viaHeader = protocolObjects.headerFactory.createViaHeader(host, port,
protocolObjects.transport, null);
newRequest.addFirst(viaHeader);
sipUri = protocolObjects.addressFactory.createSipURI("proxy", "127.0.0.1");
sipUri.setPort(5080);
sipUri.setLrParam();
sipUri.setTransportParam(protocolObjects.transport);
address = protocolObjects.addressFactory.createAddress("proxy", sipUri);
recordRoute = protocolObjects.headerFactory.createRecordRouteHeader(address);
newRequest.addHeader(recordRoute);
ClientTransaction ct2 = sipProvider.getNewClientTransaction(newRequest);
ct2.setApplicationData(st);
this.clientTxTable.add(ct2);
// Send the requests out to the two listening points of the
// client.
ct2.sendRequest();
ct1.sendRequest();
}
} else {
// Remove the topmost route header
// The route header will make sure it gets to the right place.
logger.info("proxy: Got a request " + request.getMethod());
Request newRequest = (Request) request.clone();
newRequest.removeFirst(RouteHeader.NAME);
sipProvider.sendRequest(newRequest);
}
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);