Skip to content

Commit

Permalink
made the terminate dialog on transaction termination optional.
Browse files Browse the repository at this point in the history
Related to issue usnistgov #8
  • Loading branch information
jagliot authored and jaimecasero committed Aug 24, 2017
1 parent a137bcd commit a750091
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/gov/nist/javax/sip/stack/SIPClientTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,11 @@ public abstract void processResponse(SIPResponse transactionResponse,
* @return the originalRequestFromTag
*/
public abstract String getOriginalRequestScheme();

/**
* will terminate a null state dialog when the transaction terminates
* Default: true
* @param enabled
*/
public abstract void setTerminateDialogOnCleanUp(boolean enabled);
}
19 changes: 15 additions & 4 deletions src/gov/nist/javax/sip/stack/SIPClientTransactionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ public class SIPClientTransactionImpl extends SIPTransactionImpl implements SIPC
private AtomicBoolean timerKStarted = new AtomicBoolean(false);
private boolean transactionTimerCancelled = false;
private Set<Integer> responsesReceived = new CopyOnWriteArraySet<Integer>();

private boolean terminateDialogOnCleanUp = true;

public class TransactionTimer extends SIPStackTimerTask {

Expand Down Expand Up @@ -1966,10 +1968,12 @@ protected void cleanUpOnTerminated() {
// }
}

// If dialog is null state, no response is received and we should clean it up now,
// it's hopeless to recover. Refers to this issue https://github.com/usnistgov/jsip/issues/8
if(this.defaultDialog != null && this.defaultDialog.getState() == null) {
this.defaultDialog.setState(SIPDialog.TERMINATED_STATE);
if (terminateDialogOnCleanUp) {
// If dialog is null state, no response is received and we should clean it up now,
// it's hopeless to recover. Refers to this issue https://github.com/usnistgov/jsip/issues/8
if(this.defaultDialog != null && this.defaultDialog.getState() == null) {
this.defaultDialog.setState(SIPDialog.TERMINATED_STATE);
}
}

}
Expand Down Expand Up @@ -2029,4 +2033,11 @@ public String getOriginalRequestScheme() {
return originalRequest.getRequestURI().getScheme();
}

/**
* @see gov.nist.javax.sip.stack.SIPClientTransaction#setTerminateDialogOnCleanUp(boolean)
*/
public void setTerminateDialogOnCleanUp(boolean enabled) {
terminateDialogOnCleanUp = enabled;
}

}

0 comments on commit a750091

Please sign in to comment.