/** * @param session the session to set */ public void setSipSession(MobicentsSipSession session) { // we store the session in JVM to cope with race conditions on session invalidation // See Issue 1294 http://code.google.com/p/mobicents/issues/detail?id=1294 // but it will not be persisted to avoid unecessary replication if the message is persisted this.sipSession = session; if (session != null){ this.sessionKey = session.getKey(); } else { this.sessionKey = null; } }
public boolean addSipSession(MobicentsSipSession mobicentsSipSession) { boolean wasNotPresent = this.sipSessions.add((SipSessionKey)mobicentsSipSession.getKey()); if(logger.isDebugEnabled() && wasNotPresent) { logger.debug("Added sip session " + mobicentsSipSession.getKey() + " to sip app session " + getKey()); } readyToInvalidate = false; return wasNotPresent; // sipSessionImpl.setSipApplicationSession(this); }
/** * Add a mapping between a new session and a corresponding sipSession related to a headerName. See Also getCorrespondingSipSession method. * @param newSession the new session * @param correspondingSipSession the corresponding sip session to add * @param headerName the header name */ public void addCorrespondingSipSession(MobicentsSipSession newSession, MobicentsSipSession correspondingSipSession, String headerName) { if(JoinHeader.NAME.equalsIgnoreCase(headerName)) { joinSession.putIfAbsent(newSession.getKey(), correspondingSipSession); } else if (ReplacesHeader.NAME.equalsIgnoreCase(headerName)) { replacesSession.putIfAbsent(newSession.getKey(), correspondingSipSession); } else { throw new IllegalArgumentException("headerName argument should either be one of Join or Replaces, was : " + headerName); } }
/** * {@inheritDoc} */ public SipSession getCorrespondingSipSession(SipSession sipSession, String headerName) { MobicentsSipSession correspondingSipSession = null; if(headerName.equalsIgnoreCase(JoinHeader.NAME)) { correspondingSipSession = joinSession.get(((MobicentsSipSession) sipSession).getKey()); } else if (headerName.equalsIgnoreCase(ReplacesHeader.NAME)) { correspondingSipSession = replacesSession.get(((MobicentsSipSession) sipSession).getKey()); } else { throw new IllegalArgumentException("headerName argument should either be one of Join or Replaces"); } return correspondingSipSession; }
/** * For debugging: return a list of all session ids currently active * */ public String listSipSessionIds() { StringBuffer sb=new StringBuffer(); Iterator<MobicentsSipSession> sipSessions = sipManagerDelegate.getAllSipSessions(); while (sipSessions.hasNext()) { sb.append(sipSessions.next().getKey()).append(" "); } return sb.toString(); }
public void addDerivedSipSessions(MobicentsSipSession derivedSession) { if(derivedSipSessions == null) { this.derivedSipSessions = new ConcurrentHashMap<String, MobicentsSipSession>(); } derivedSipSessions.putIfAbsent(derivedSession.getKey().getToTag(), derivedSession); } /*
/** * For debugging: return a list of all session ids currently active * */ public String listSipSessionIds() { StringBuffer sb=new StringBuffer(); Iterator<MobicentsSipSession> sipSessions = sipManagerDelegate.getAllSipSessions(); while (sipSessions.hasNext()) { sb.append(sipSessions.next().getKey()).append(" "); } return sb.toString(); }
public MobicentsSipSessionKey getKey() { return getSipSession().getKey(); }
public MobicentsSipSessionFacade(MobicentsSipSession sipSession) { this.sipSession = sipSession; this.sipSessionKey = sipSession.getKey(); this.sipAppSessionKey = sipSession.getSipApplicationSession().getKey(); }
State.TERMINATED.equals(((MobicentsSipSession)session2).getState()) || !session1.getApplicationSession().equals(session2.getApplicationSession()) || (sessionMap.get(((MobicentsSipSession)session1).getKey()) != null && sessionMap.get(((MobicentsSipSession)session1).getKey()) != ((MobicentsSipSession)session2).getKey()) || (sessionMap.get(((MobicentsSipSession)session2).getKey()) != null && sessionMap.get(((MobicentsSipSession)session2).getKey()) != ((MobicentsSipSession)session1).getKey())) { throw new IllegalArgumentException("either of the specified sessions has been terminated " + "or the sessions do not belong to the same application session or " + "one or both the sessions are already linked with some other session(s)"); this.sessionMap.put(((MobicentsSipSession)session1).getKey(), ((MobicentsSipSession)session2).getKey()); this.sessionMap.put(((MobicentsSipSession)session2).getKey(), ((MobicentsSipSession) session1).getKey()); } else { Map<MobicentsSipSessionKey, MobicentsSipSessionKey> forkedSessionMap = ((MobicentsSipSession)session1).getB2buaHelper().getSessionMap(); forkedSessionMap.put(((MobicentsSipSession)session1).getKey(), ((MobicentsSipSession)session2).getKey()); forkedSessionMap.put(((MobicentsSipSession)session2).getKey(), ((MobicentsSipSession) session1).getKey()); } else { Map<MobicentsSipSessionKey, MobicentsSipSessionKey> forkedSessionMap = ((MobicentsSipSession)session2).getB2buaHelper().getSessionMap(); forkedSessionMap.put(((MobicentsSipSession)session1).getKey(), ((MobicentsSipSession)session2).getKey()); forkedSessionMap.put(((MobicentsSipSession)session2).getKey(), ((MobicentsSipSession) session1).getKey()); logger.debug("sipsession " + ((MobicentsSipSession)session1).getKey() + " linked to sip session " + ((MobicentsSipSession)session2).getKey());
logger.debug("Trying to remove sip session " + mobicentsSipSession); final SipSessionKey key = (SipSessionKey) mobicentsSipSession.getKey(); if(itDerivedSessions.hasNext()) { if(logger.isDebugEnabled()) { logger.debug("parent session " + parentSession.getKey() + " still contains derived sip sessions so not removing"); logger.debug("Derived sip sessions left are : "); while (itDerivedSessions.hasNext()) { MobicentsSipSession derivedSipSession = itDerivedSessions.next(); logger.debug("Derived sip session : " + derivedSipSession.getKey() + " isValid " + derivedSipSession.isValidInternal() + " isReadyToInvalidate " + derivedSipSession.isReadyToInvalidateInternal()); logger.debug("not removing parent sip session " + parentSession.getKey() + " without derived sessions since it's still valid"); if(itDerivedSessions.hasNext()) { if(logger.isDebugEnabled()) { logger.debug("Sip Session " + mobicentsSipSession.getKey() + " still contains derived sip sessions so not removing"); logger.debug("Derived sip sessions left are : "); while (itDerivedSessions.hasNext()) { MobicentsSipSession derivedSipSession = itDerivedSessions.next(); logger.debug("Derived sip session : " + derivedSipSession.getKey() + " isValid " + derivedSipSession.isValidInternal() + " isReadyToInvalidate " + derivedSipSession.isReadyToInvalidateInternal());
@Override public boolean equals(Object obj) { if(obj instanceof MobicentsSipSession) { MobicentsSipSession sipSession = (MobicentsSipSession)obj; if(sipSession.getKey().equals(getKey())) { // Issue 2365 : Derived Sessions should be equal only if their to tag is equal if(sipSession.getKey().getToTag() == null && getKey().getToTag() == null) { return true; } if(sipSession.getKey().getToTag() != null && getKey().getToTag() != null && sipSession.getKey().getToTag().equals(getKey().getToTag())) { return true; } else { return false; } } else { return false; } } return false; } @Override
protected MobicentsSipSession setToTag(final SipSessionKey key, final MobicentsSipSession sipSession) { final String currentKeyToTag = key.getToTag(); final MobicentsSipSessionKey existingKey = sipSession.getKey(); final String toTag = existingKey.getToTag(); if(logger.isDebugEnabled()) {
/** * {@inheritDoc} */ public SipServletRequest createCancel(SipSession session) { if(session == null) throw new NullPointerException("The session for createCancel cannot be null"); for (SipServletRequestImpl linkedRequest : originalRequestMap.keySet()) { if(linkedRequest.getSipSessionKey().equals(((MobicentsSipSession) session).getKey()) && linkedRequest.getMethod().equalsIgnoreCase(Request.INVITE) && !linkedRequest.isFinalResponseGenerated() && // Fix for Issue http://code.google.com/p/mobicents/issues/detail?id=2114 // In B2b servlet, after re-INVITE, and try to create CANCEL will get "final response already sent!" exception. linkedRequest.getLastFinalResponse() == null) { final SipServletRequestImpl sipServletRequestImpl = (SipServletRequestImpl)linkedRequest.createCancel(); ((MobicentsSipSession)sipServletRequestImpl.getSession()).setB2buaHelper(this); return sipServletRequestImpl; } } return null; }
" to following App/ruby controller => " + response.getSipSession().getKey().getApplicationName()+ "/" + sipContext.getSipRubyController().getName()); if(logger.isDebugEnabled()) { logger.debug("Dispatching response " + response.toString() + " to following App/servlet => " + session.getKey().getApplicationName()+ "/" + session.getHandler() + " on following sip session " + session.getId());
this.transaction = transaction; if(sipSession != null) { this.sessionKey = sipSession.getKey();
MobicentsSipSession mobicentsSipSession = (MobicentsSipSession) sipSessionsIt .next(); MobicentsSipSessionKey sessionKey = mobicentsSipSession.getKey(); if(sessionKey.getCallId().trim().equals(dialog.getCallId().getCallId())) { if(logger.isDebugEnabled()) {
public SipSession getSession(boolean create) { MobicentsSipSession session = getSipSession(); if (session == null && create) { MobicentsSipApplicationSession sipApplicationSessionImpl = (MobicentsSipApplicationSession)getSipApplicationSession(create); MobicentsSipSessionKey sessionKey = SessionManagerUtil.getSipSessionKey(sipApplicationSessionImpl.getKey().getId(), currentApplicationName, message, false); session = sipApplicationSessionImpl.getSipContext().getSipManager().getSipSession(sessionKey, create, sipFactoryImpl, sipApplicationSessionImpl); session.setSessionCreatingTransactionRequest(this); session.setOrphan(isOrphan()); sessionKey = session.getKey(); } if(session != null) { return session.getFacade(); } return null; }
if(logger.isDebugEnabled()) { logger.debug("Created derived session " + sipSessionImpl + " with sessionKey " + sessionKey + " for parent session " + parentSipSession + " with parent session key " + parentSipSession.getKey());