use of gov.nist.javax.sip.header.extensions.ReplacesHeader in project load-balancer by RestComm.
the class TestSipListener method processAck.
public void processAck(Request request, ServerTransaction serverTransactionId) {
try {
logger.info("shootist: got a " + request);
logger.info("shootist: got an ACK. ServerTxId = " + serverTransactionId);
ackReceived = true;
// we don't count retransmissions
if (serverTransactionId != null) {
ackCount++;
}
if (testAckViaParam) {
ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
String param = viaHeader.getParameter("testAckViaParam");
if (param != null) {
abortProcessing = true;
logger.error("the Via Param set in the response shouldn't be present in the ACK");
return;
}
}
if (sendBye) {
Thread.sleep(timeToWaitBeforeBye);
if (serverTransactionId != null && serverTransactionId.getDialog() != null) {
Request byeRequest = serverTransactionId.getDialog().createRequest(Request.BYE);
logger.info("BYE created : " + byeRequest);
ClientTransaction ct = sipProvider.getNewClientTransaction(byeRequest);
logger.info("Sending BYE : " + byeRequest);
serverTransactionId.getDialog().sendRequest(ct);
logger.info("Dialog State = " + serverTransactionId.getDialog().getState());
}
}
if (!joinRequestReceived && sendJoinMessage) {
String fromUser = "join";
String fromHost = "sip-servlets.com";
SipURI fromAddress = protocolObjects.addressFactory.createSipURI(fromUser, fromHost);
String toUser = "join-receiver";
String toHost = "sip-servlets.com";
SipURI toAddress = protocolObjects.addressFactory.createSipURI(toUser, toHost);
CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
ToHeader toHeader = (ToHeader) request.getHeader(ToHeader.NAME);
JoinHeader joinHeader = (JoinHeader) ((HeaderFactoryExt) protocolObjects.headerFactory).createJoinHeader(callIdHeader.getCallId(), toHeader.getTag(), fromHeader.getTag());
sendSipRequest("MESSAGE", fromAddress, toAddress, joinHeader.toString(), null, false);
}
if (!isReplacesRequestReceived() && sendReplacesMessage) {
String fromUser = "replaces";
String fromHost = "sip-servlets.com";
SipURI fromAddress = protocolObjects.addressFactory.createSipURI(fromUser, fromHost);
String toUser = "replaces-receiver";
String toHost = "sip-servlets.com";
SipURI toAddress = protocolObjects.addressFactory.createSipURI(toUser, toHost);
CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
ToHeader toHeader = (ToHeader) request.getHeader(ToHeader.NAME);
ReplacesHeader replacesHeader = (ReplacesHeader) ((HeaderFactoryExt) protocolObjects.headerFactory).createReplacesHeader(callIdHeader.getCallId(), toHeader.getTag(), fromHeader.getTag());
sendSipRequest("MESSAGE", fromAddress, toAddress, replacesHeader.toString(), null, false);
}
if (joinRequestReceived) {
sendBye();
sendBye(joinDialog);
}
if (isReplacesRequestReceived()) {
sendBye();
sendBye(replacesDialog);
}
if (sendReinvite && !reinviteSent) {
List<Header> headers = new ArrayList<Header>();
Header reinviteHeader = protocolObjects.headerFactory.createHeader("ReInvite", "true");
headers.add(reinviteHeader);
sendInDialogSipRequest("INVITE", null, null, null, headers, null);
reinviteSent = true;
return;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations