Request ackRequest = dialog.createAck(cseq.getSequenceNumberLong());
Request ackRequest = dialog.createAck(cseq.getSeqNumber());
	public 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);		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());		try {			if (response.getStatusCode() == Response.OK) {				logger.info("response = " + response);				if (cseq.getMethod().equals(Request.INVITE)) {					Request ackRequest = dialog.createAck(cseq.getSequenceNumberLong());					logger.info("Sending ACK");					dialog.sendAck(ackRequest);				} 			} else if  (response.getStatusCode() == Response.MOVED_TEMPORARILY) {				// Dialog dies as soon as you get an error response.				assertTrue(tid.getDialog().getState() == DialogState.TERMINATED);				assertTrue(tid.getDialog() == this.dialog);				this.redirectReceived = true;				if (cseq.getMethod().equals(Request.INVITE)) {					// lookup the contact header					ContactHeader contHdr = (ContactHeader) response							.getHeader(ContactHeader.NAME);					// we can re-use the from header					FromHeader from = ((FromHeader) response							.getHeader(FromHeader.NAME));					// we use the to-address, but without the tag					ToHeader to = (ToHeader) (response.getHeader(ToHeader.NAME)).clone();					to.removeParameter("tag");					// the call-id can be re-used					CallIdHeader callID = ((CallIdHeader) response							.getHeader(CallIdHeader.NAME));					// we take the next cseq					int seqNo = (((CSeqHeader) response							.getHeader(CSeqHeader.NAME)).getSequenceNumber());					logger.info("seqNo = " + seqNo);					CSeqHeader cseqNew = protocolObjects.headerFactory							.createCSeqHeader(++seqNo, "INVITE");					// Create ViaHeaders (either use tcp or udp)					ArrayList viaHeaders = new ArrayList();					ViaHeader viaHeader = protocolObjects.headerFactory							.createViaHeader("127.0.0.1", sipProvider									.getListeningPoint(protocolObjects.transport).getPort(), 									protocolObjects.transport,									null);					// add via headers					viaHeaders.add(viaHeader);					// create max forwards					MaxForwardsHeader maxForwardsHeader = protocolObjects.headerFactory							.createMaxForwardsHeader(10);					// create invite Request					SipURI newUri = (SipURI)this.requestURI.clone();					newUri.setParameter("redirection", "true");									Request invRequest = protocolObjects.messageFactory							.createRequest(newUri,									"INVITE", callID, cseqNew, from, to,									viaHeaders, maxForwardsHeader);					// we set the Request URI to the address given					SipURI contactURI = 					protocolObjects.addressFactory.createSipURI(null, this.listeningPoint.getIPAddress());										contactURI.setPort(this.listeningPoint.getPort());					contactURI.setTransportParam(protocolObjects.transport);										Address address = protocolObjects.addressFactory.createAddress(contactURI);					ContactHeader contact = protocolObjects.headerFactory.createContactHeader(address);					invRequest.addHeader(contact);										// the contacat header in the response contains where to redirect					// the request to -- which in this case happens to be back to the					// same location.					ContactHeader chdr = (ContactHeader)response.getHeader(ContactHeader.NAME);										SipURI sipUri = (SipURI)chdr.getAddress().getURI();					sipUri.setLrParam();					RouteHeader routeHeader = 						protocolObjects.headerFactory.createRouteHeader(chdr.getAddress());					invRequest.addHeader(routeHeader);									logger.info("Sending INVITE to "							+ contHdr.getAddress().getURI().toString());					inviteTid = sipProvider.getNewClientTransaction(invRequest);					this.transactionCount++;										logger.info("New TID = " + inviteTid);					inviteTid.sendRequest();					assertTrue(inviteTid.getState() == TransactionState.CALLING);					logger.info("sendReqeust succeeded " + inviteTid);					Dialog dialog = inviteTid.getDialog();					assertTrue("Stack must allocate a new dialog", dialog != this.dialog);					this.dialogCount ++;					this.dialog = dialog;										}			}			/**			 * end of modified code			 */		} catch (Exception ex) {			ex.printStackTrace();			fail("unexpeced exception");		}	}