public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
logger.info("Got a response");
Response response = (Response) responseReceivedEvent.getResponse();
ClientTransaction tid = responseReceivedEvent.getClientTransaction();
CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
logger.info("Response received : Status Code = "
+ response.getStatusCode() + " " + cseq);
logger.info("Response = " + response + " class=" + response.getClass() );
Dialog dialog = responseReceivedEvent.getDialog();
TestHarness.assertNotNull( dialog );
if (tid != null)
logger.info("transaction state is " + tid.getState());
else
logger.info("transaction = " + tid);
logger.info("Dialog = " + dialog);
logger.info("SHOOTIST: Dialog state is " + dialog.getState());
try {
if (response.getStatusCode() == Response.OK) {
if (cseq.getMethod().equals(Request.INVITE)) {
TestHarness.assertEquals( DialogState.CONFIRMED, dialog.getState() );
Request ackRequest = dialog.createAck(cseq
.getSeqNumber());
TestHarness.assertNotNull( ackRequest.getHeader( MaxForwardsHeader.NAME ) );
// Proxy will fork. I will accept the second dialog
// but not the first.
this.forkedDialogs.add(dialog);
dialog.sendAck(ackRequest);
if ( forkedDialogs.size() == 2 ) {
logger.info("Sending ACK");
TestHarness.assertTrue(
"Dialog state should be CONFIRMED", dialog
.getState() == DialogState.CONFIRMED);
this.ackedDialog = dialog;
// TestHarness.assertNotNull( "JvB: Need CT to find original dialog", tid );
} else {
// Kill the first dialog by sending a bye.
SipProvider sipProvider = (SipProvider) responseReceivedEvent
.getSource();
Request byeRequest = dialog.createRequest(Request.BYE);
ClientTransaction ct = sipProvider
.getNewClientTransaction(byeRequest);
dialog.sendRequest(ct);
}
} else {
logger.info("Response method = " + cseq.getMethod());
}
} else if ( response.getStatusCode() == Response.RINGING ) {
//TestHarness.assertEquals( DialogState.EARLY, dialog.getState() );
}
} catch (Throwable ex) {