use of javax.sip.InvalidArgumentException in project load-balancer by RestComm.
the class Shootist method processInvite.
public void processInvite(Request request, ServerTransaction stx) {
try {
inviteRequest = request;
Response response = messageFactory.createResponse(180, request);
contactHeader = headerFactory.createContactHeader(addressFactory.createAddress("sip:here@" + localIPAddress + ":" + localPort));
response.addHeader(contactHeader);
dialog = stx.getDialog();
// check removing incorrect patching last via https://github.com/RestComm/load-balancer/issues/97
FromHeader fromHeader = (FromHeader) response.getHeader(From.NAME);
URI currUri = fromHeader.getAddress().getURI();
String fromUser = null;
if (currUri.isSipURI()) {
fromUser = ((SipURI) currUri).getUser();
if (fromUser.equals("senderToNexmo")) {
ViaHeader lastViaHeader = null;
ListIterator<ViaHeader> it = response.getHeaders(ViaHeader.NAME);
while (it.hasNext()) lastViaHeader = it.next();
lastViaHeader.setReceived("127.0.0.2");
lastViaHeader.setParameter("rport", "1111");
}
}
stx.sendResponse(response);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response = messageFactory.createResponse(200, request);
contactHeader = headerFactory.createContactHeader(addressFactory.createAddress("sip:here@" + localIPAddress + ":" + localPort));
response.addHeader(contactHeader);
dialog = stx.getDialog();
stx.sendResponse(response);
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations