Package javax.servlet.sip

Examples of javax.servlet.sip.SipServletRequest


    proxy(getSipFactory().createURI(uri));
  }
 
  public void proxy(URI uri) throws TooManyHopsException
  {
    SipServletRequest request = getRequest();
    Proxy proxy = request.getProxy();
    proxy.setSupervised(true);
    proxy.proxyTo(uri);
  }
View Full Code Here


    try
    {
      SipSession session = subscription.getSession();
      if (session.isValid())
      {
        SipServletRequest notify = session.createRequest(Constants.NOTIFY);
        notify.addHeader(Constants.EVENT, getName());
       
        String s = subscription.getState().getName();
        if (subscription.getState() == Subscription.State.ACTIVE
            || subscription.getState() == Subscription.State.PENDING)
          s = s + ";expires=" + ((subscription.getExpirationTime()-System.currentTimeMillis()) / 1000);
        notify.addHeader(Constants.SUBSCRIPTION_STATE, s);
       
        State state;
        if (subscription.isAuthorized())
          state = subscription.getResource().getState();
        else
          state = subscription.getResource().getNeutralState();
        preprocessState(session, state);
        ContentHandler handler = getContentHandler(state.getContentType());
        byte[] b = handler.getBytes(state.getContent());
       
        notify.setContent(b, state.getContentType());
        notify.send();
      }
      else
        _log.warn("Could not send notification to {} for event {} as sip session is invalidated",
            subscription, getName());
    }
View Full Code Here

            throw new IllegalArgumentException("Invalid expression: route after " + token);
    }
   
    public Object extract(Object input)
    {
        SipServletRequest request = (SipServletRequest) input;
        return request.getPoppedRoute();
    }
View Full Code Here

    return request;
  }
 
  protected SipServletRequest createRegister(SipSession session)
  {
    SipServletRequest register;
    if (session == null)
      register = createRequest(SipMethods.REGISTER, _localAddress);
    else
      register = createRequest(session, SipMethods.REGISTER);
     
    SipURI registrar = _factory.createSipURI(null, ((SipURI) _localAddress.getURI()).getHost());
    register.setRequestURI(registrar);
    register.setAddressHeader(SipHeaders.CONTACT, _contact);
    register.setExpires(3600);
   
    return register;
  }
View Full Code Here

 
  public synchronized void startRegistration() throws IOException
  {
    if (_registerSession == null)
    {
      SipServletRequest register = createRegister(null);
      _registerSession = register.getSession();
      _registerSession.setAttribute(MessageHandler.class.getName(), new RegistrationHandler());
      register.send();
    }
  }
View Full Code Here

    SipApplicationSession session = _sipFactory.createApplicationSession();
    synchronized (_calls)
    {
      _calls.add(session);
   
    SipServletRequest request = _sipFactory.createRequest(session, "INVITE", from, to);
    if (_b2bHelper == null)
      _b2bHelper = request.getB2buaHelper();
    request.getSession().setHandler(getServletName());
    request.send();
  }
View Full Code Here

 
  public synchronized void stopRegistration() throws IOException
  {
    if (_registerSession != null)
    {
      SipServletRequest register = createRegister(_registerSession);
      register.setExpires(0);
      register.send();
    }
  }
View Full Code Here

      if ("BYE".equals(method))
      {
        List<SipServletMessage> list = b2bHelper.getPendingMessages(leg2, UAMode.UAC);
        if (list.size() == 1)
        {
          SipServletRequest invite = (SipServletRequest) list.get(0);
          invite.createCancel().send();
          request.createResponse(SipServletResponse.SC_OK).send();
          leg2.getApplicationSession().invalidate();
        }
        else
          log("Could not found initial INVITE");
View Full Code Here

        doInitialInviteResponse(response);
        return;
      }
     
      B2buaHelper b2bHelper = response.getRequest().getB2buaHelper();
      SipServletRequest peerRequest = b2bHelper.getLinkedSipServletRequest(response.getRequest());
   
      // Peer request could be null is case of 4xx/INVITE response by leg B.
      if (peerRequest != null)
      {
        peerRequest.createResponse(response.getStatus(), response.getReasonPhrase()).send();
      }
    }
    catch (Throwable e)
    {
      log("Unable to process response:\n" + response, e);
View Full Code Here

    {
      if (status >= SipServletResponse.SC_OK
          && status < SipServletResponse.SC_MULTIPLE_CHOICES)
      {
        // Create second leg               
        SipServletRequest request = _sipFactory.createRequest(response.getApplicationSession(),
            response.getMethod(),
            response.getTo(),
            response.getFrom());
        copy(response, request);

        b2bHelper.linkSipSessions(leg1, request.getSession());

        request.setAttribute(RESP_INV, response);
        request.getSession().setHandler(getServletName());

        // if leg2 took more than 10s to pick up call, cancel it.
        ServletTimer cancelCallTask = _timerService.createTimer(leg1.getApplicationSession(), 15000,
            false, new CancelCallTask(leg1, request));
       
        leg1.setAttribute(CancelCallTask.class.getName(), cancelCallTask);
       
        request.send();
      }
      else if (response.getStatus() >= SipServletResponse.SC_MULTIPLE_CHOICES)
      {
        response.getApplicationSession().invalidate();
      }
    }
    else
    {
      if (status >= SipServletResponse.SC_OK
          && status < SipServletResponse.SC_MULTIPLE_CHOICES)
      { 
        ((ServletTimer) leg2.getAttribute(CancelCallTask.class.getName())).cancel();
       
        // ACK to leg2
        SipServletResponse leg2Resp = (SipServletResponse) response.getRequest().getAttribute(RESP_INV);
        SipServletRequest request = leg2Resp.createAck();
        copy(response, request);
        request.send();
       
        // ACK to leg1
        response.createAck().send();
      }
      else if (status >= SipServletResponse.SC_MULTIPLE_CHOICES)
View Full Code Here

TOP

Related Classes of javax.servlet.sip.SipServletRequest

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.