/** * This method is called immediately when the conditions for read to invalidate * session are met */ public void onReadyToInvalidate() { this.setReadyToInvalidate(true); if(logger.isDebugEnabled()) { logger.debug("invalidateWhenReady flag is set to " + invalidateWhenReady); } if(isValid() && this.invalidateWhenReady) { this.notifySipSessionListeners(SipSessionEventType.READYTOINVALIDATE); //If the application does not explicitly invalidate the session in the callback or has not defined a listener, //the container will invalidate the session. if(isValid()) { invalidate(true); } } }
@Override protected MobicentsSipSession getNewMobicentsSipSession(SipSessionKey key, SipFactoryImpl sipFactoryImpl, MobicentsSipApplicationSession mobicentsSipApplicationSession) { if ((maxActiveSipSessions >= 0) && (sipSessions.size() >= maxActiveSipSessions)) { rejectedSipSessions++; throw new IllegalStateException ("could not create a new sip session because there is currently too many active sip sessions"); } sipSessionCounter++; return new SipSessionImpl(key, sipFactoryImpl, mobicentsSipApplicationSession); }
/** * Setting ackReceived for CSeq to specified value in second param. * if the second param is true it will try to cleanup earlier cseq as well to save on memory * @param cSeq cseq to set the ackReceived * @param ackReceived whether or not the ack has been received for this cseq */ public void setAckReceived(long cSeq, boolean ackReceived) { if(logger.isDebugEnabled()) { logger.debug("setting AckReceived to : " + ackReceived + " for CSeq " + cSeq); } acksReceived.put(cSeq, ackReceived); if(ackReceived) { cleanupAcksReceived(cSeq); } }
public Object getAttribute(String name) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } return getAttributeMap().get(name); }
/** * Add an ongoing tx to the session. */ public void addOngoingTransaction(Transaction transaction) { if(transaction != null && ongoingTransactions != null && !isReadyToInvalidate() ) { boolean added = this.ongoingTransactions.add(transaction); if(added) { if(logger.isDebugEnabled()) { logger.debug("transaction "+ transaction +" has been added to sip session's ongoingTransactions" ); } setReadyToInvalidate(false); } } }
if(getSessionCreatingDialog() == null && proxy == null) { response.getStatus() >= 200 && response.getStatus() != 407 && response.getStatus() != 401) { if(logger.isDebugEnabled()) { logger.debug("Setting SipSession " + getKey() + " for response " + response.getStatus() + " to a non dialog creating or terminating request " + method + " in state " + state + " to ReadyToInvalidate=true"); setReadyToInvalidate(true); response.getStatus() >= 200 && response.getStatus() < 300 && !JainSipUtils.DIALOG_TERMINATING_METHODS.contains(method)) { this.setState(State.CONFIRMED); if(this.proxy != null && response.getProxyBranch() != null && !response.getProxyBranch().getRecordRoute()) { setReadyToInvalidate(true); logger.debug("the following sip session " + getKey() + " has its state updated to " + state); this.setState(State.EARLY); if(logger.isDebugEnabled()) { logger.debug("the following sip session " + getKey() + " has its state updated to " + state); setState(State.INITIAL); logger.debug("the following sip session " + getKey() + " has its state updated to " + state); setState(State.TERMINATED); if(logger.isDebugEnabled()) { logger.debug("the following sip session " + getKey() + " has its state updated to " + state);
final MobicentsSipApplicationSession sipApplicationSession = getSipApplicationSession(); SipManager manager = sipApplicationSession.getSipContext().getSipManager(); MobicentsSipSession parentSipSession = getParentSession(); if(parentSipSession == null) { if(derivedSipSessions == null || derivedSipSessions.isEmpty()) { removeAttribute(key, true); removeAttribute(key, true); notifySipSessionListeners(SipSessionEventType.DELETION); cleanDialogInformation(true);
if(eventHeader != null) { if(logger.isDebugEnabled()) { logger.debug("removing subscription " + eventHeader + " to sip session " + getId()); if(subscriptions.size() < 1) { if((originalMethod != null && okToByeSentOrReceived) || !Request.INVITE.equals(originalMethod) ) { setState(State.TERMINATED); if(isReadyToInvalidateInternal()) { if(logger.isDebugEnabled()) { logger.debug("no more subscriptions in session " + getId());
boolean resetLocalCSeq = true; if(isAck && isAckReceived(remoteCSeq)) { logger.debug("localCSeq : " + localCseq + ", remoteCSeq : " + remoteCSeq); setAckReceived(remoteCSeq, true); logger.error("CSeq out of order for the following request " + sipServletRequest); if(Request.INVITE.equalsIgnoreCase(method)) { setAckReceived(remoteCSeq, false); setCseq(remoteCSeq); if(Request.INVITE.equalsIgnoreCase(method)) { setAckReceived(remoteCSeq, false);
public void removeAttribute(String name, boolean byPassValidCheck) { if(!byPassValidCheck && !isValid()) throw new IllegalStateException("Can not bind object to session that has been invalidated!!"); Object value = getAttributeMap().get(name); this.getAttributeMap().remove(name); SipListeners sipListenersHolder = this.getSipApplicationSession().getSipContext().getListeners(); List<SipSessionAttributeListener> listenersList = sipListenersHolder.getSipSessionAttributeListeners(); if(listenersList.size() > 0) {
private void updateReadyToInvalidate(Transaction transaction) { // Section 6.2.4.1.2 Invalidate When Ready Mechanism : // "The container determines the SipSession to be in the ready-to-invalidate state under any of the following conditions: // 3. A SipSession acting as a UAC transitions from the EARLY state back to // the INITIAL state on account of receiving a non-2xx final response (6.2.1 Relationship to SIP Dialogs, point 4) // and has not initiated any new requests (does not have any pending transactions)." if(logger.isDebugEnabled()) { if(ongoingTransactions != null) { logger.debug("ongoingTransactions " + ongoingTransactions.isEmpty() + " for sipsession " + key); } else { logger.debug("ongoingTransactions " + null + " for sipsession " + key); } } if(!readyToInvalidate && (ongoingTransactions == null || ongoingTransactions.isEmpty()) && transaction instanceof ClientTransaction && getProxy() == null && state != null && state.equals(State.INITIAL) && // Fix for Issue 1734 sessionCreatingTransactionRequest != null && sessionCreatingTransactionRequest.getLastFinalResponse() != null && sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() >= 300) { setReadyToInvalidate(true); } }
public void setState(State state) { this.state = state; if(state == State.TERMINATED) { setReadyToInvalidate(true); } }
@Override public void setState(State state) { super.setState(state); sessionMetadataDirty(); metaModifiedMap_.put(STATE, state); }
@Override public void setCseq(long cseq) { super.setCseq(cseq); sessionMetadataDirty(); metaModifiedMap_.put(CSEQ, cseq); }
public Map<String, Object> getSipSessionAttributeMap() { return getAttributeMap(); } /*
public MobicentsSipSession findDerivedSipSession(String toTag) { dumpDerivedSipSessions(); if(derivedSipSessions != null) { return derivedSipSessions.get(toTag); } return null; }
public void access() { super.access(); // JBAS-3528. If it's not the first access, make sure // the 'new' flag is correct //SipSession doesn't have the isNew flag // if (!firstAccess && isNew) { // setNew(false); // } sessionLastAccessTimeDirty(); // if (invalidationPolicy == WebMetaData.SESSION_INVALIDATE_ACCESS) { // this.sessionMetadataDirty(); // } }
originalMethod = sessionCreatingTransactionRequest.getMethod(); addOngoingTransaction(sessionCreatingTransactionRequest.getTransaction());
public void setAttribute(String key, Object attribute) { if(!isValid()) { throw new IllegalStateException("Can not bind object to session that has been invalidated!!"); Object oldValue = getAttributeMap().get(key); if (attribute != oldValue) { event = new SipSessionBindingEvent(this, key); Object previousValue = this.getAttributeMap().put(key, attribute); SipListeners sipListenersHolder = this.getSipApplicationSession().getSipContext().getListeners(); List<SipSessionAttributeListener> listenersList = sipListenersHolder.getSipSessionAttributeListeners(); if(listenersList.size() > 0) {