/** * Sets the to tag on the key when we receive a response. * We recompute the session id only for derived session otherwise the id will change * when the a request is received or sent and the response is sent back or received which should not happen * See TCK test SipSessionListenerTest.testSessionDestroyed001 * * @param toTag the toTag to set * @param recomputeSessionId check if the sessionid need to be recomputed */ public void setToTag(String toTag, boolean recomputeSessionId) { this.toTag = toTag; if(toTag != null && recomputeSessionId) { // Issue 2365 : to tag needed for getApplicationSession().getSipSession(<sessionId>) to return forked session and not the parent one computeToString(); } }
public String getId() { return key.toString(); }
/** * Parse a sip application key that was previously generated and put as an http request param * through the encodeURL method of SipApplicationSession * @param sipSessionKey the stringified version of the sip application key * @return the corresponding sip application session key * @throws ParseException if the stringfied key cannot be parse to a valid key */ public static SipSessionKey parseHaSipSessionKey( String sipSessionKey, String sipAppSessionId, String sipApplicationName) throws ParseException { if(logger.isDebugEnabled()) { logger.debug("sipSession ha key to parse " + sipSessionKey ); } StringTokenizer stringTokenizer = new StringTokenizer(sipSessionKey, SESSION_KEY_SEPARATOR); String fromTag = stringTokenizer.nextToken(); String callId = stringTokenizer.nextToken(); return new SipSessionKey(fromTag, null, callId, sipAppSessionId, sipApplicationName); }
public static String getSipSessionHaKey(SipSessionKey key) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(key.getFromTag()).append(SESSION_KEY_SEPARATOR).append(key.getCallId()); return stringBuilder.toString(); } }
applicationSessionId = sipApplicationSessionImpl.getKey().getId(); } else { applicationSessionId = key.getApplicationSessionId(); throw (RuntimeException) ex; throw new RuntimeException("Failed to load session " + key.toString(), ex); } finally { try { if (doTx) endTransaction(key.toString()); } finally { ConvergedSessionReplicationContext.finishSipCacheActivity(); unloadedSipSessions_.remove(key.toString()); stats_.updateLoadStats(key.toString(), elapsed); log_.debug("loadSession(): id= " + key.toString() + ", session=" + session); log_.debug("loadSession(): session " + key.toString() + " not found in distributed cache");
public void run() { final SipContext sipContext = sipFactoryImpl.getSipApplicationDispatcher().findSipApplication(key.getApplicationName()); if(sipContext != null) { SipManager sipManager = sipContext.getSipManager(); final SipApplicationSessionKey sipApplicationSessionKey = SessionManagerUtil.getSipApplicationSessionKey( key.getApplicationName(), key.getApplicationSessionId(), null); MobicentsSipApplicationSession sipApplicationSession = sipManager.getSipApplicationSession(sipApplicationSessionKey, false);
protected MobicentsSipSession setToTag(final SipSessionKey key, final MobicentsSipSession sipSession) { final String currentKeyToTag = key.getToTag(); final MobicentsSipSessionKey existingKey = sipSession.getKey(); final String toTag = existingKey.getToTag(); " creates new derived session with following to Tag " + currentKeyToTag ); key.setToTag(currentKeyToTag, true); derivedSipSession = createDerivedSipSession(sipSession, key); } else {
public void setHandler(String name) throws ServletException { if(!isValid()) { throw new IllegalStateException("the session has already been invalidated, no handler can be set on it anymore !"); } if(name != null && name.equals(handlerServlet)) { return ; } SipContext sipContext = getSipApplicationSession().getSipContext(); MobicentsSipServlet container = sipContext.findSipServletByName(name); if(container == null && sipContext.getSipRubyController() == null) { throw new ServletException("the sip servlet with the name "+ name + " doesn't exist in the sip application " + sipContext.getApplicationName()); } this.handlerServlet = name; getSipApplicationSession().setCurrentRequestHandler(handlerServlet); if(logger.isDebugEnabled()) { if(name !=null) { logger.debug("Session Handler for application " + getKey().getApplicationName() + " set to " + handlerServlet + " on sip session " + key); } else { logger.debug("Session Handler for application " + getKey().getApplicationName() + " set to " + sipContext.getSipRubyController() + " on sip session " + key); } } }
@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
@Override public int hashCode() { return getKey().hashCode(); } @Override
public String getCallId() { if(this.sessionCreatingDialog != null) return this.sessionCreatingDialog.getCallId().getCallId(); else if(sessionCreatingTransactionRequest != null) return ((CallIdHeader)this.sessionCreatingTransactionRequest.getMessage().getHeader(CallIdHeader.NAME)).getCallId(); else if(key != null) return key.getCallId(); else return null; }
logger.debug("resetting the to tag since a response to a non dialog creating and terminating method has been received for non proxy session with no dialog in state " + state); key.setToTag(null, false); logger.debug("resetting the to tag since a non 2xx response has been received for non proxy session in state " + state); key.setToTag(null, false);
public MobicentsSipApplicationSession getSipApplicationSession() { if(sipApplicationSession == null) { final String applicationName = key.getApplicationName(); final SipContext sipContext = sipFactory.getSipApplicationDispatcher().findSipApplication(applicationName); if(sipContext != null) { sipApplicationSession = sipContext.getSipManager().getSipApplicationSession(sipApplicationSessionKey, false); } } return sipApplicationSession; }
sipManager.dumpSipSessions(); } else if (((SipStackImpl)sipApplicationDispatcher.getSipStack()).getMaxForkTime() > 0) { logger.debug("trying to find derived session to Tag " + sessionKey.getToTag()); MobicentsSipSession derivedSipSession = tmpSession.findDerivedSipSession(sessionKey.getToTag()); if(derivedSipSession != null) { tmpSession = derivedSipSession;
@Override public String toString() { return getKey().toString(); } public SipApplicationRouterInfo getNextSipApplicationRouterInfo() {
/** * @param fromAddress * @param fromTag * @param toAddress * @param toTag * @param callId * @param applicationSessionId * @param applicationName */ public SipSessionKey(String fromTag, String toTag, String callId, String applicationSessionId, String applicationName) { super(); this.fromTag = fromTag; this.toTag = toTag; this.callId = callId; this.applicationName = applicationName; this.applicationSessionId = applicationSessionId; computeToString(); } /**
if(logger.isDebugEnabled()) { logger.debug("notifying sip session listener " + sipSessionListener.getClass().getName() + " of context " + key.getApplicationName() + " of following event " + sipSessionEventType);
String applicationName = stringTokenizer.nextToken(); return new SipSessionKey(fromTag, toTag, callId, applicationSessionId, applicationName);
/** * */ public void dumpSipSessions() { if(logger.isDebugEnabled()) { logger.debug("sip sessions present in the session manager"); Enumeration<SipSessionKey> keys = sipSessions.keys(); while(keys.hasMoreElements()) { logger.debug(keys.nextElement().toString()); } } }