* @param transaction
* is the transaction to add to the dialog.
*/
public boolean addTransaction(SIPTransaction transaction) {
SIPRequest sipRequest = (SIPRequest) transaction.getOriginalRequest();
// Proessing a re-invite.
if (firstTransactionSeen
&& !firstTransactionId.equals(transaction.getBranchId())
&& transaction.getMethod().equals(firstTransactionMethod)) {
setReInviteFlag(true);
}
if (sipStack.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
sipStack.getStackLogger().logDebug(
"SipDialog.addTransaction() " + this + " transaction = "
+ transaction);
}
if (firstTransactionSeen == false) {
// Record the local and remote sequenc
// numbers and the from and to tags for future
// use on this dialog.
storeFirstTransactionInfo(this, transaction);
if (sipRequest.getMethod().equals(Request.SUBSCRIBE))
this.eventHeader = (EventHeader) sipRequest
.getHeader(EventHeader.NAME);
this.setLocalParty(sipRequest);
this.setRemoteParty(sipRequest);
this.setCallId(sipRequest);
if (this.originalRequest == null
&& transaction.isInviteTransaction()) {
this.originalRequest = sipRequest;
} else if (originalRequest != null) {
originalRequestRecordRouteHeaders = sipRequest
.getRecordRouteHeaders();
}
if (this.method == null) {
this.method = sipRequest.getMethod();
}
if (transaction instanceof SIPServerTransaction) {
this.hisTag = sipRequest.getFrom().getTag();
// My tag is assigned when sending response
} else {
setLocalSequenceNumber(sipRequest.getCSeq().getSeqNumber());
this.originalLocalSequenceNumber = localSequenceNumber;
this.setLocalTag(sipRequest.getFrom().getTag());
if (myTag == null)
if (sipStack.isLoggingEnabled())
sipStack
.getStackLogger()
.logError(
"The request's From header is missing the required Tag parameter.");
}
} else if (transaction.getMethod().equals(firstTransactionMethod)
&& firstTransactionIsServerTransaction != transaction
.isServerTransaction()) {
// This case occurs when you are processing a re-invite.
// Switch from client side to server side for re-invite
// (put the other side on hold).
storeFirstTransactionInfo(this, transaction);
this.setLocalParty(sipRequest);
this.setRemoteParty(sipRequest);
this.setCallId(sipRequest);
if (transaction.isInviteTransaction()) {
this.originalRequest = sipRequest;
} else {
originalRequestRecordRouteHeaders = sipRequest
.getRecordRouteHeaders();
}
this.method = sipRequest.getMethod();
} else if (firstTransaction == null
&& transaction.isInviteTransaction()) {
// jeand needed for reinvite reliable processing
firstTransaction = transaction;
}
if (transaction instanceof SIPServerTransaction) {
setRemoteSequenceNumber(sipRequest.getCSeq().getSeqNumber());
}
// If this is a server transaction record the remote
// sequence number to avoid re-processing of requests
// with the same sequence number directed towards this