}
public void processResponse(ResponseEvent responseReceivedEvent) {
logger.info("Got a response");
Response response = (Response) responseReceivedEvent.getResponse();
Transaction tid = responseReceivedEvent.getClientTransaction();
logger.info("Response received with client transaction id " + tid
+ ":\n" + response.getStatusCode());
if (tid == null) {
logger.info("Stray response -- dropping ");
return;
}
logger.info("transaction state is " + tid.getState());
logger.info("Dialog = " + tid.getDialog());
logger.info("Dialog State is " + tid.getDialog().getState());
SipProvider provider = (SipProvider) responseReceivedEvent.getSource();
try {
CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
if (response.getStatusCode() == Response.OK
&& cseq.getMethod().equals(Request.INVITE)) {
// Request cancel = inviteTid.createCancel();
// ClientTransaction ct =
// sipProvider.getNewClientTransaction(cancel);
Dialog dialog = tid.getDialog();
Request ackRequest = dialog.createAck(cseq.getSeqNumber());
TlsTest.assertTrue( "Secure URI",
((SipURI)ackRequest.getRequestURI()).isSecure() );
logger.info("Ack request to send = " + ackRequest);
logger.info("Sending ACK");
dialog.sendAck(ackRequest);
// Send a Re INVITE but this time force it
// to use UDP as the transport. Else, it will
// Use whatever transport was used to create
// the dialog.
if (reInviteCount == 0) {
Request inviteRequest = dialog
.createRequest(Request.INVITE);
Thread.sleep(100);
ClientTransaction ct = provider
.getNewClientTransaction(inviteRequest);
dialog.sendRequest(ct);
reInviteCount++;
} else {
this.okReceived = true;
}
} else if (response.getStatusCode() == Response.OK
&& ((CSeqHeader) response.getHeader(CSeqHeader.NAME))
.getMethod().equals(Request.BYE)) {
this.byeOkRecieved = true;
}
} catch (Exception ex) {
logger.error(ex);