Examples of SIPRequest


Examples of org.cipango.server.SipRequest

    return _listener;
  }
 
  private void ack(SipResponse response)
    {
    SipRequest ack = getRequest().createRequest(SipMethods.ACK);
   
    if (ack.to().getParameter("tag") == null)
        {
      String tag = response.to().getParameter("tag");
      if (tag != null)
        ack.to().setParameter("tag", tag);
    }
    try
        {
      getServer().getConnectorManager().send(ack, getConnection());
    }
View Full Code Here

Examples of org.cipango.server.SipRequest

public class SipHeaderTest
{
  @Test
  public void testAddress() throws Exception
  {
    SipRequest request = new SipRequest();
    Address address = new NameAddr("sip:foo");
    try
    {
      request.addAddressHeader("From", address, false);
      fail("system header");
    }
    catch (IllegalArgumentException e)
    {
    }
   
    try
    {
      request.addAddressHeader("Expires", address, false);
      fail("not address header");
    }
    catch (IllegalArgumentException e)
    {
    }
   
    request.addAddressHeader("foo", address, false);
    assertEquals("foo", ((SipURI) request.getAddressHeader("FOO").getURI()).getHost());
   
    request.addAddressHeader("bar", new ReadOnlyAddress(address), false);
    assertEquals("foo", ((SipURI) request.getAddressHeader("Bar").getURI()).getHost());
   
    request.setAddressHeader("bar", new ReadOnlyAddress(address));
    assertEquals("foo", ((SipURI) request.getAddressHeader("Bar").getURI()).getHost());
  }
View Full Code Here

Examples of org.cipango.server.SipRequest

            String cid = ID.newCallId(appSession.getCallSession().getId());
           
            Session session = appSession.createUacSession(cid, local, remote);
            session.setHandler(getSipServletHandler().getDefaultServlet());
           
            SipRequest request = (SipRequest) session.createRequest(method);
            request.setInitial(true);
            request.setRoutingDirective(SipApplicationRoutingDirective.NEW, null);
          
            return request;
        }
View Full Code Here

Examples of org.cipango.server.SipRequest

            return createRequest(appSession, method, createAddress(from), createAddress(to));
        }
       
        public SipServletRequest createRequest(SipServletRequest srcRequest, boolean sameCallId)
        {
          SipRequest origRequest = (SipRequest) srcRequest;
         
          NameAddr local = (NameAddr) origRequest.from().clone();
          local.setParameter(SipParams.TAG, ID.newTag());
         
          NameAddr remote = (NameAddr) origRequest.to().clone();
          remote.removeParameter(SipParams.TAG);
         
          String callId = null;
         
          if (sameCallId)
            callId = origRequest.getCallId();
          else
            callId = ID.newCallId(origRequest.getCallId());
         
            AppSession appSession = ((SipRequest) srcRequest).appSession();
           
            Session session = appSession.createUacSession(callId, local, remote);
            session.setHandler(getSipServletHandler().getDefaultServlet());

            SipRequest request = session.getUA().createRequest((SipRequest) srcRequest);
            request.setRoutingDirective(SipApplicationRoutingDirective.CONTINUE, srcRequest);
            request.setInitial(true);
           
            return request;
        }
View Full Code Here

Examples of org.cipango.server.SipRequest

      _localCSeq = other._localCSeq;
    }
   
    public SipRequest createRequest(SipRequest srcRequest)
    {
      SipRequest request = (SipRequest) srcRequest.clone();
           
            request.getFields().remove(SipHeaders.RECORD_ROUTE_BUFFER);
            request.getFields().remove(SipHeaders.VIA_BUFFER);
            request.getFields().remove(SipHeaders.CONTACT_BUFFER);
           
            setDialogHeaders(request, _localCSeq++);
               
      //request.setInitial(true);
      request.setSession(Session.this);
     
      return request;
    }
View Full Code Here

Examples of org.cipango.server.SipRequest

      return createRequest(SipMethods.ACK, _localCSeq);
    }
   
    public SipServletRequest createRequest(String method, long cseq)
    {
      SipRequest request = new SipRequest();
      request.setMethod(method.toUpperCase());
     
      setDialogHeaders(request, cseq);
     
      request.setSession(Session.this);
     
      if (_state == State.INITIAL)
        request.setInitial(true);
      return request;
    }
View Full Code Here

Examples of org.cipango.server.SipRequest

        tx.setListener(this);
      }
     
      updateState(response, false);
     
      SipRequest request = (SipRequest) response.getRequest();

      if (request.isInitial() && (response.to().getParameter(SipParams.TAG) == null))
      {
        String tag = _localParty.getParameter(SipParams.TAG);
        if (tag == null)
          tag = ID.newTag();
        response.to().setParameter(SipParams.TAG, tag);
      }
     
      if (request.isInvite() || request.isSubscribe())
        setRemoteTarget(request);
     
      if (request.isInvite())
      {
        int status = response.getStatus();
        long cseq = response.getCSeq().getNumber();
       
        if (200 <= status && (status < 300))
View Full Code Here

Examples of org.cipango.server.SipRequest

                        _localParty.setParameter(SipParams.TAG, tag);
                    }
                    response.to().setParameter(SipParams.TAG, tag);
                }*/
               
                SipRequest request = (SipRequest) response.getRequest();
         
        _remoteCSeq = request.getCSeq().getNumber();
        _secure = request.isSecure() && request.getRequestURI().getScheme().equals("sips");
       
        setRoute(request, false);
      }
    }
View Full Code Here

Examples of org.cipango.server.SipRequest

 
  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

Examples of org.cipango.server.SipRequest

    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
TOP
Copyright © 2018 www.massapi.com. 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.