Package org.cipango.server

Examples of org.cipango.server.SipResponse


    }
   
    @Override
    public void startResponse(Buffer version, int status, Buffer reason) throws IOException
    {
      SipResponse response = new SipResponse();
      response.setStatus(status, reason.toString());
      _message = response;
    }
View Full Code Here


  {
    if (_sipMessage.isRequest())
      return _sipMessage.getMethod() + " " + ((SipServletRequest) _sipMessage).getRequestURI();
    else
    {
      SipResponse response = (SipResponse) _sipMessage;
      return response.getStatus() + " " + response.getReasonPhrase();
    }
  }
View Full Code Here

      _aDelay = _aDelay * 2;
      startTimer(TIMER_A, _aDelay);
      break;
    case TIMER_B:
      cancelTimer(TIMER_A);
      SipResponse responseB = create408();
      // TODO send to ??
            if (!_cancel)
                _listener.handleResponse(responseB);
      terminate();
            break;
        case TIMER_D:
            terminate();
            break;
           
        case TIMER_E:
            try
            {
                doSend();
            }
            catch (IOException e)
            {
                Log.debug("Failed to (re)send request " + _request);
            }
            if (_state == STATE_TRYING)
                _eDelay = Math.min(_eDelay * 2, __T2);
            else
                _eDelay = __T2;
            startTimer(TIMER_E, _eDelay);
            break;
        case TIMER_F:
            cancelTimer(TIMER_E);
            SipResponse responseF = create408();
            if (!_cancel)
                _listener.handleResponse(responseF); // TODO interface TU
            terminate();
            break;
        case TIMER_K:
View Full Code Here

  }

  public SipResponse create408()
  {
    // could not use request.createResponse() because the request is committed.
    SipResponse responseB = new SipResponse(_request, SipServletResponse.SC_REQUEST_TIMEOUT, null);
    if (responseB.getTo().getParameter(SipParams.TAG) == null)
      responseB.setToTag(ID.newTag());
   
    AccessLog accessLog = getServer().getConnectorManager().getAccessLog();
    if (accessLog != null)
      accessLog.messageReceived(responseB, new TimeoutConnection());
   
View Full Code Here

    }
   
    public void handleRetransmission(SipRequest request)
    {
      // TODO cseq
      SipResponse response = null;
     
      if (_state == STATE_PROCEEDING)
        response = _provisionalResponse;
      else if (_state == STATE_COMPLETED)
        response = _finalResponse;
View Full Code Here

      if (handler == null)
      {
        Log.debug("SIP application {} has no matching servlet for {}", appContext.getName(), request.getMethod());
        if (!request.isAck())
        {           
          SipResponse response = (SipResponse) request.createResponse(SipServletResponse.SC_NOT_FOUND);
          response.to().setParameter(SipParams.TAG, ID.newTag());
          ((ServerTransaction) request.getTransaction()).send(response);
        }
        return;
      }
     
      AppSession appSession;
     
      String key = (String) request.getHandlerAttribute(ID.SESSION_KEY_ATTRIBUTE);
     
      if (key != null)
      {
        String id = ID.getIdFromKey(appContext.getName(), key);
        appSession = request.getCallSession().getAppSession(id);
        if (appSession == null)
          appSession = request.getCallSession().createAppSession(appContext, id);
      }
      else
      {
        appSession = request.getCallSession().createAppSession(appContext, ID.newAppSessionId());
      }
       
      session = appSession.createSession();
      session.setHandler(handler);
       
      session.setSubscriberURI(request.getSubscriberURI());
      session.setRegion(request.getRegion());
   
          if (Log.isDebugEnabled())
              Log.debug("new session {}", session);
    }
    else
    {
      session = request.getCallSession().findSession(request);
     
      if (session == null)
            {
        if (!request.isAck())
                {
          SipResponse response = (SipResponse) request.createResponse(SipServletResponse.SC_CALL_LEG_DONE);
          ((ServerTransaction) request.getTransaction()).send(response);
        }
        return;
      }
    }
    if (request.isInvite())
        {
      SipResponse response = (SipResponse) request.createResponse(SipServletResponse.SC_TRYING);
      ((ServerTransaction) request.getTransaction()).send(response);
    }
   
    request.setSession(session);
       
        try
        {
            session.handleRequest(request);
        }
        catch (Exception e)
        {
          if (!request.isAck() && !request.isCommitted())
          {
            int code = SipServletResponse.SC_SERVER_INTERNAL_ERROR;
            if (e instanceof SipException)
              code = ((SipException) e).getCode();
           
            SipServletResponse response;
            if (code == SipServletResponse.SC_SERVER_INTERNAL_ERROR)
            {
              response = request.createResponse(
                    SipServletResponse.SC_SERVER_INTERNAL_ERROR,
                    "Error in handler: " + e.getMessage());
              ExceptionUtil.fillStackTrace(response, e);
            }
            else
            {
              response = request.createResponse(code);
            }
            response.send();
          }
          else
          {
            Log.debug(e);
          }
View Full Code Here

        {
          ServerInvite invite = (ServerInvite) LazyList.get(_serverInvites, i);
          for (int j = LazyList.size(invite._reliable1xxs); j-->0;)
          {
            ServerInvite.Reliable1xx reliable1xx = (ServerInvite.Reliable1xx) LazyList.get(invite._reliable1xxs, j);
            SipResponse response = reliable1xx.getResponse();
            if (response != null && !response.isCommitted())
            {
              if (list == null)
                list = new ArrayList<SipServletResponse>();
              list.add(response);
            }
          }
        }
      }
      else
      {
        for (int i = LazyList.size(_clientInvites); i-->0;)
        {
          ClientInvite invite = (ClientInvite) LazyList.get(_clientInvites, i);
          for (int j = LazyList.size(invite._reliable1xxs); j-->0;)
          {
            ClientInvite.Reliable1xxClient reliable1xx = (ClientInvite.Reliable1xxClient) LazyList.get(invite._reliable1xxs, j);
            SipResponse response = reliable1xx.getResponse();
            if (response != null && !response.isCommitted())
            {
              if (list == null)
                list = new ArrayList<SipServletResponse>();
              list.add(response);
            }
View Full Code Here

      if (mode == UAMode.UAS)
      {
        for (int i = LazyList.size(_serverInvites); i-->0;)
        {
          ServerInvite invite = (ServerInvite) LazyList.get(_serverInvites, i);
          SipResponse response = invite.getResponse();
          if (response != null && !response.isCommitted())
          {
            if (list == null)
              list = new ArrayList<SipServletResponse>();
            list.add(response);
          }
View Full Code Here

        }
        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);
View Full Code Here

    catch (Exception e)
    {
      if (!request.isAck())
      {
        // Could have ServletParseException or IllegalArgumentException on pushRoute
        SipResponse response = (SipResponse) request.createResponse(
                SipServletResponse.SC_SERVER_INTERNAL_ERROR,
                "Error in handler: " + e.getMessage());
        ExceptionUtil.fillStackTrace(response, e);
        try { getConnectorManager().sendResponse(response); } catch (Exception e1) {Log.ignore(e1); }
      }
View Full Code Here

TOP

Related Classes of org.cipango.server.SipResponse

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.