Package org.cipango.server

Examples of org.cipango.server.SipRequest$IteratorToEnum


 
  public void handle(SipServletMessage message) throws ServletException, IOException
    {
    if (((SipMessage) message).isRequest())
    {
      SipRequest request = (SipRequest) message;
   
      Address route = popLocalRoute(request);
     
      if (isInitial(request))
          {
        request.setInitial(true);
       
        SipApplicationRouterInfo routerInfo = null;
        SipAppContext appContext = null;
       
        try
        {
          if (route != null)
          {
            SipURI uri = (SipURI) route.getURI();
            if (RouterInfoUtil.ROUTER_INFO.equals(uri.getUser()))
            {
              routerInfo = RouterInfoUtil.decode(uri);
              route = popLocalRoute(request);
            }
            if (route != null)
              request.setPoppedRoute(route);
          }
         
          if (routerInfo == null)
          {
            routerInfo = ((Server) getServer()).getApplicationRouter().getNextApplication(
              request, null, SipApplicationRoutingDirective.NEW, null, null);
          }
        }
        catch (Throwable t)
        {
          if (!request.isAck())
          {
            SipResponse response = new SipResponse(
                request,
                SipServletResponse.SC_SERVER_INTERNAL_ERROR,
                "Application router error: " + t.getMessage());
            ExceptionUtil.fillStackTrace(response, t);
            getConnectorManager().sendResponse(response);
          }
          return;
        }
       
        if (routerInfo != null && routerInfo.getNextApplicationName() != null)
        {
          boolean handle = handlingRoute(request, routerInfo);
          if (handle)
            return;
         
          request.setStateInfo(routerInfo.getStateInfo());
          request.setRegion(routerInfo.getRoutingRegion());
         
          String s = routerInfo.getSubscriberURI();
          if (s != null)
          {
            try
            {
              request.setSubscriberURI(URIFactory.parseURI(s));
            }
            catch (ServletParseException e)
            {
              Log.debug(e);
            }
          }
         
          String applicationName = routerInfo.getNextApplicationName();
          appContext = (SipAppContext) getContext(applicationName);
                   
          Method method = appContext == null ? null : appContext.getSipApplicationKeyMethod();
          if (method != null)
          {
            try
            {
              String sessionKey = (String) method.invoke(null, request);
             
              if (Log.isDebugEnabled())
                Log.debug("routing initial request to key {}", sessionKey);
             
              request.addHandlerAttribute(ID.SESSION_KEY_ATTRIBUTE, sessionKey);
            }
            catch (Exception e)
            {
              Log.debug("failed to get SipApplicationKey", e);
            }
          }
         
          if (Log.isDebugEnabled())
            Log.debug("application router returned application {} for initial request {}", applicationName, request.getMethod());
          if (appContext == null && applicationName != null)
            Log.debug("No application with name {} returned by application router could be found", applicationName, null);
        }
       
        if (appContext == null)
        {
         
          if (!request.isAck())
          {
            SipResponse response = new SipResponse(request, SipServletResponse.SC_NOT_FOUND, null);
            response.to().setParameter(SipParams.TAG, ID.newTag());
            getConnectorManager().sendResponse(response);
          }
          return;
        }     
        request.addHandlerAttribute(ID.CONTEXT_ATTRIBUTE, appContext);
      }
      else
      {
        if (route != null)
          request.setPoppedRoute(route);
      }
    }   
    _handler.handle(message);
    }
View Full Code Here


    public void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException
    {
      try
      {
        URI ruri = URIFactory.parseURI(uri.toString());
        SipRequest request = new SipRequest();
        request.setMethod(method.toString());
        request.setRequestURI(ruri);
        _message = request;
      }
      catch (Exception e)
      {
        throw new IOException("Parsing error: " + e.getMessage());
View Full Code Here

 
  public String getCallSessionId(SipMessage message)
  {   
    if (message.isRequest())
    {
      SipRequest request = (SipRequest) message;
     
      if (request.isInitial())
      {
        String sessionKey = (String) request.getHandlerAttribute(ID.SESSION_KEY_ATTRIBUTE);
     
        if (sessionKey != null)
        {
          SipAppContext context = (SipAppContext) request.getHandlerAttribute(ID.CONTEXT_ATTRIBUTE);
          return ID.getIdFromKey(context.getName(), sessionKey);
        }
      }
      else
      {   
        String appSessionId = request.getParameter(ID.APP_SESSION_ID_PARAMETER);
        if (appSessionId != null && ID.isKey(appSessionId))
          return appSessionId;
      }
    }
    else
View Full Code Here

    _state = newState;
  }
 
  public void updateState(SipResponse response, boolean uac)
  {
    SipRequest request = (SipRequest) response.getRequest();
    int status = response.getStatus();
       
    if (request.isInitial() && (request.isInvite() || request.isSubscribe()))
    {
      switch (_state)
      {
      case INITIAL:
        if (status < 300)
        {
          if (_ua != null)
            _ua.createDialog(response, uac);
          else if (isProxy())
            createProxyDialog(response);
         
          if (status < 200)
            setState(State.EARLY);
          else
            setState(State.CONFIRMED);
        }
        else
        {
          if (uac)
          {
            _ua.resetDialog();
            setState(State.INITIAL);
          }
          else
          {
            setState(State.TERMINATED);
          }
        }
        break;
      case EARLY:
        if (200 <= status && status < 300)
        {
          setState(State.CONFIRMED);
        }
        else if (status >= 300)
        {
          if (uac)
            setState(State.INITIAL);
          else
            setState(State.TERMINATED);
        }
        break;
      }
    }
    else if (request.isBye())
    {
      setState(State.TERMINATED);
    }
  }
View Full Code Here

TOP

Related Classes of org.cipango.server.SipRequest$IteratorToEnum

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.