//switch to confirmed state
dialog.receivedOrSent2xx();
//generate ack
//p. 82 §3
SipRequest ack = dialog.buildSubsequentRequest(RFC3261.METHOD_ACK);
//update CSeq
SipHeaders ackHeaders = ack.getSipHeaders();
SipHeaderFieldName cseqName = new SipHeaderFieldName(RFC3261.HDR_CSEQ);
SipHeaderFieldValue ackCseq = ackHeaders.get(cseqName);
SipRequest request = transaction.getRequest();
SipHeaders requestHeaders = request.getSipHeaders();
SipHeaderFieldValue requestCseq = requestHeaders.get(cseqName);
ackCseq.setValue(requestCseq.toString().replace(RFC3261.METHOD_INVITE, RFC3261.METHOD_ACK));
//add Via with only the branchid parameter
SipHeaderFieldValue via = new SipHeaderFieldValue("");
SipHeaderParamName branchIdName = new SipHeaderParamName(RFC3261.PARAM_BRANCH);
via.addParam(branchIdName, Utils.generateBranchId());
ackHeaders.add(new SipHeaderFieldName(RFC3261.HDR_VIA), via, 0);
//TODO authentication headers
if (request.getBody() == null && sipResponse.getBody() != null) {
//TODO add a real SDP answer
ack.setBody(sipResponse.getBody());
}
//TODO check if sdp is acceptable