if ( ! cancelSent ) { cancelSent = true; sendCancel();
if (!cancelSent) { if (! sendDelayedCancel) sendCancel();
	public void processResponse(ResponseEvent responseReceivedEvent) {		System.out.println("Got a response");		Response response = (Response) responseReceivedEvent.getResponse();		ClientTransaction tid = responseReceivedEvent.getClientTransaction();		CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);		System.out.println(			"Response received : Status Code = "				+ response.getStatusCode() + " " + cseq);		if (tid == null) {			System.out.println("Stray response -- dropping ");			return;		}		System.out.println("transaction state is " + tid.getState());		System.out.println("Dialog = " + tid.getDialog());		System.out.println("Dialog State is " + tid.getDialog().getState());		try {			if (   response.getStatusCode() == Response.OK  ) {			      if ( cseq.getMethod().equals(Request.INVITE) ) {				   Request ackRequest = dialog.createRequest(Request.ACK);				   System.out.println("Sending ACK");				   dialog.sendAck(ackRequest);			      } else if ( cseq.getMethod().equals( Request.CANCEL) ) {				if (  dialog.getState() == DialogState.CONFIRMED) {					// oops cancel went in too late. Need to hang up the dialog.				        System.out.println("Sending BYE -- cancel went in too late !!");					Request byeRequest = dialog.createRequest ( Request.BYE);					ClientTransaction ct = udpProvider.getNewClientTransaction ( byeRequest );					dialog.sendRequest ( ct );				}			      }			} else if (response.getStatusCode() == Response.REQUEST_TERMINATED) {				Request ackRequest = tid.createAck();				ClientTransaction ct = udpProvider.getNewClientTransaction(ackRequest);				ct.sendRequest();			} else if ( response.getStatusCode() == Response.RINGING) {				// Cancel the invite.				if ( ! cancelSent ) {					cancelSent = true;					 sendCancel();				}			}					} catch (Exception ex) {			ex.printStackTrace();			System.exit(0);		}	}