public synchronized void processResponse(ResponseEvent responseReceived) {
logger.info("Got a response");
ResponseEventExt responseReceivedEvent = (ResponseEventExt) responseReceived;
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();
if(createDialogAfterRequest) {
TestCase.assertNull( dialog );
return;
} else {
TestCase.assertNotNull( dialog );
}
System.out.println("original Tx " + responseReceivedEvent.getOriginalTransaction());
if ( cseq.getMethod().equals(Request.INVITE)) {
TestCase.assertSame("Must preserve original dialog",
this.originalDialog,responseReceivedEvent.getOriginalTransaction().getDefaultDialog());
}
if (tid != null)
logger.info("transaction state is " + tid.getState());
else
logger.info("transaction = " + tid);
logger.info("Dialog = " + dialog);
logger.info("Dialog state is " + dialog.getState());
try {
if (response.getStatusCode() == Response.OK) {
if (cseq.getMethod().equals(Request.INVITE)) {
TestCase.assertEquals( DialogState.CONFIRMED, dialog.getState() );
Request ackRequest = dialog.createAck(cseq
.getSeqNumber());
TestCase.assertNotNull( ackRequest.getHeader( MaxForwardsHeader.NAME ) );
dialog.sendAck(ackRequest);
// Proxy will fork. I will accept the first dialog.
this.forkedDialogs.add(dialog);
if ( responseReceivedEvent.getClientTransaction() != null ) {
this.originalTransaction = responseReceivedEvent.getClientTransaction();
logger.info("Sending ACK");
TestCase.assertTrue(
"Dialog state should be CONFIRMED", dialog
.getState() == DialogState.CONFIRMED);
TestCase.assertTrue(this.ackedDialog == null ||
this.ackedDialog == dialog);
this.ackedDialog = dialog;
if ( callerSendsBye ) {
timer.schedule( new SendBye(ackedDialog), 4000 );
}
} else {
ResponseEventExt responseEventExt = (ResponseEventExt) responseReceivedEvent;
TestCase.assertTrue("forked event must set flag",responseEventExt.isForkedResponse());
this.canceledDialog.add(dialog);
SipProvider sipProvider = (SipProvider) responseReceivedEvent
.getSource();
TestCase.assertSame("original ctx must match " ,
responseEventExt.getOriginalTransaction(),this.originalTransaction);
Request byeRequest = dialog.createRequest(Request.BYE);
ClientTransaction ct = sipProvider
.getNewClientTransaction(byeRequest);
dialog.sendRequest(ct);
}
} else if ( cseq.getMethod().equals(Request.BYE)) {
if ( dialog == this.ackedDialog) {
this.byeResponseSeen = true;
}
} else {
logger.info("Response method = " + cseq.getMethod());
}
} else if ( response.getStatusCode() == Response.RINGING ) {
//TestHarness.assertEquals( DialogState.EARLY, dialog.getState() );
}
} catch (Throwable ex) {