Package org.cipango.kaleo.presence.watcherinfo

Examples of org.cipango.kaleo.presence.watcherinfo.WatcherResource


        subscribe.getApplicationSession().invalidate();
        return;
      }
    }
       
    WatcherResource resource = _watcherInfo.get(uri);
   
    String subscriberUri = null;
    if (subscribe.getAddressHeader(Constants.P_ASSERTED_IDENTITY) != null)
      subscriberUri = URIUtil.toCanonical(subscribe.getAddressHeader(Constants.P_ASSERTED_IDENTITY).getURI());
    else
      subscriberUri = URIUtil.toCanonical(subscribe.getFrom().getURI());
   
    try
    {
      Subscription subscription = null;
     
      if (expires == 0)
      {
        subscription = resource.removeSubscription(session.getId());
       
        if (subscription == null)
          subscription = new Subscription(resource, session, -1, subscriberUri);
        else
        {
          subscription.setExpirationTime(System.currentTimeMillis());
          if (_log.isDebugEnabled())
            _log.debug("removed presence.winfo subscription {} to resource {}",
              subscription.getSession().getId(), resource.getUri());
       
        subscription.setState(Subscription.State.TERMINATED, Reason.TIMEOUT);
      }
      else
      {
        long now = System.currentTimeMillis();
       
        subscription = resource.getSubscription(session.getId());
   
        if (subscription == null)
        {
          subscription = new Subscription(resource, session, now + expires*1000, subscriberUri);
          subscription.setState(State.ACTIVE, Reason.SUBSCRIBE);
          resource.addSubscription(subscription);
         
          session.setAttribute(Constants.SUBSCRIPTION_ATTRIBUTE, uri);
         
          if (_log.isDebugEnabled())
            _log.debug("added presence.winfo subscription {} to resource {}",
                subscription.getSession().getId(), resource.getUri());
        }
        else
        {
          subscription.setExpirationTime(now + expires * 1000);
         
          if (_log.isDebugEnabled())
            _log.debug("refreshed presence.winfo subscription {} to resource {}",
                subscription.getSession().getId(), resource.getUri());
        }
      }
     
      int code = (subscription.getState() != Subscription.State.PENDING) ?
          SipServletResponse.SC_OK : SipServletResponse.SC_ACCEPTED;
View Full Code Here


  private static final String SUBSCRIBER_AOR = "sip:bob@cipango.org";

  public void testGetState() throws Exception
  {
    Presentity presentity = new Presentity(AOR);
    WatcherResource resource = new WatcherResource(AOR, presentity);
    EventListener eventListener = new EventListener();
    resource.addListener(eventListener);
    //System.out.println(resource.getState().getContent());
    Watcherinfo watcherinfo = ((WatcherinfoDocument) resource.getState().getContent()).getWatcherinfo();
    assertEquals(State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    WatcherList watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(AOR, watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
View Full Code Here

TOP

Related Classes of org.cipango.kaleo.presence.watcherinfo.WatcherResource

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.