Class ServerSessionImpl

java.lang.Object
org.cometd.server.ServerSessionImpl
All Implemented Interfaces:
org.cometd.bayeux.server.ServerSession, org.cometd.bayeux.Session, org.eclipse.jetty.util.component.Dumpable

public class ServerSessionImpl
extends java.lang.Object
implements org.cometd.bayeux.server.ServerSession, org.eclipse.jetty.util.component.Dumpable
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ServerSession

    org.cometd.bayeux.server.ServerSession.AddListener, org.cometd.bayeux.server.ServerSession.DeQueueListener, org.cometd.bayeux.server.ServerSession.Extension, org.cometd.bayeux.server.ServerSession.HeartBeatListener, org.cometd.bayeux.server.ServerSession.MaxQueueListener, org.cometd.bayeux.server.ServerSession.MessageListener, org.cometd.bayeux.server.ServerSession.QueueListener, org.cometd.bayeux.server.ServerSession.RemoveListener, org.cometd.bayeux.server.ServerSession.ServerSessionListener
  • Field Summary

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    KEY
  • Constructor Summary

    Constructors 
    Constructor Description
    ServerSessionImpl​(BayeuxServerImpl bayeux)  
    ServerSessionImpl​(BayeuxServerImpl bayeux, LocalSessionImpl localSession, java.lang.String idHint)  
  • Method Summary

    Modifier and Type Method Description
    protected void added()  
    void addExtension​(org.cometd.bayeux.server.ServerSession.Extension extension)  
    void addListener​(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)  
    protected void addMessage​(org.cometd.bayeux.server.ServerMessage message)  
    void batch​(java.lang.Runnable batch)  
    long calculateInterval​(long defaultInterval)  
    long calculateTimeout​(long defaultTimeout)  
    void cancelExpiration​(boolean metaConnect)  
    protected boolean connected()  
    void deliver​(org.cometd.bayeux.Session sender, java.lang.String channelId, java.lang.Object data, org.cometd.bayeux.Promise<java.lang.Boolean> promise)  
    void deliver​(org.cometd.bayeux.Session sender, org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)  
    protected void deliver1​(org.cometd.bayeux.server.ServerSession sender, org.cometd.bayeux.server.ServerMessage.Mutable mutable, org.cometd.bayeux.Promise<java.lang.Boolean> promise)  
    void destroyScheduler()  
    void disconnect()  
    void dump​(java.lang.Appendable out, java.lang.String indent)  
    boolean endBatch()  
    protected void extendIncoming​(org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)  
    protected void extendOutgoing​(org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<org.cometd.bayeux.server.ServerMessage.Mutable> promise)  
    void flush()  
    java.lang.Object getAttribute​(java.lang.String name)  
    java.util.Set<java.lang.String> getAttributeNames()  
    BayeuxServerImpl getBayeuxServer()  
    java.lang.String getBrowserId()  
    java.util.List<org.cometd.bayeux.server.ServerSession.Extension> getExtensions()  
    java.lang.String getId()  
    long getInterval()  
    java.util.List<org.cometd.bayeux.server.ServerSession.ServerSessionListener> getListeners()  
    org.cometd.bayeux.server.LocalSession getLocalSession()  
    java.lang.Object getLock()  
    long getMaxInterval()  
    java.util.Queue<org.cometd.bayeux.server.ServerMessage> getQueue()  
    org.cometd.bayeux.server.ServerTransport getServerTransport()  
    java.util.Set<org.cometd.bayeux.server.ServerChannel> getSubscriptions()  
    long getTimeout()  
    java.lang.String getUserAgent()  
    protected boolean handshake​(org.cometd.bayeux.server.ServerMessage.Mutable message)  
    boolean hasNonLazyMessages()  
    boolean isAllowMessageDeliveryDuringHandshake()  
    boolean isBroadcastToPublisher()  
    boolean isConnected()  
    boolean isDisconnected()  
    boolean isHandshook()  
    boolean isLocalSession()  
    boolean isMetaConnectDeliveryOnly()  
    boolean isTerminated()  
    void notifyResumed​(org.cometd.bayeux.server.ServerMessage message, boolean timeout)  
    void notifySuspended​(org.cometd.bayeux.server.ServerMessage message, long timeout)  
    void reAdvise()  
    java.lang.Object removeAttribute​(java.lang.String name)  
    protected boolean removed​(boolean timedOut)  
    void removeExtension​(org.cometd.bayeux.server.ServerSession.Extension extension)  
    void removeListener​(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)  
    void scheduleExpiration​(long defaultInterval, long defaultMaxInterval)  
    void setAllowMessageDeliveryDuringHandshake​(boolean allow)  
    void setAttribute​(java.lang.String name, java.lang.Object value)  
    void setBroadcastToPublisher​(boolean value)  
    void setBrowserId​(java.lang.String browserId)
    Sets a remote client identifier, typically a browser.
    void setInterval​(long intervalMS)  
    void setMaxInterval​(long maxInterval)  
    void setMetaConnectDeliveryOnly​(boolean meta)  
    void setScheduler​(AbstractServerTransport.Scheduler newScheduler)  
    void setServerTransport​(org.cometd.bayeux.server.ServerTransport transport)  
    void setTimeout​(long timeoutMS)  
    void setUserAgent​(java.lang.String userAgent)  
    boolean shouldSchedule()  
    void startBatch()  
    protected boolean subscribe​(ServerChannelImpl channel)  
    protected void sweep​(long now)  
    java.util.Map<java.lang.String,​java.lang.Object> takeAdvice​(org.cometd.bayeux.server.ServerTransport transport)  
    java.util.List<org.cometd.bayeux.server.ServerMessage> takeQueue​(java.util.List<org.cometd.bayeux.server.ServerMessage.Mutable> replies)  
    java.lang.String toString()  
    protected void unsubscribedFrom​(ServerChannelImpl channel)  
    void updateTransientInterval​(long interval)
    Updates the transient interval with the given value.
    void updateTransientTimeout​(long timeout)
    Updates the transient timeout with the given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dump, dumpSelf

    Methods inherited from interface org.cometd.bayeux.server.ServerSession

    deliver, deliver
  • Constructor Details

  • Method Details

    • getBayeuxServer

      public BayeuxServerImpl getBayeuxServer()
    • getUserAgent

      public java.lang.String getUserAgent()
      Specified by:
      getUserAgent in interface org.cometd.bayeux.server.ServerSession
      Returns:
      the remote user agent
    • setUserAgent

      public void setUserAgent​(java.lang.String userAgent)
      Parameters:
      userAgent - the remote user agent
    • getBrowserId

      public java.lang.String getBrowserId()
      Returns:
      the remote client identifier
    • setBrowserId

      public void setBrowserId​(java.lang.String browserId)

      Sets a remote client identifier, typically a browser.

      Parameters:
      browserId - the remote client identifier
    • sweep

      protected void sweep​(long now)
    • getSubscriptions

      public java.util.Set<org.cometd.bayeux.server.ServerChannel> getSubscriptions()
      Specified by:
      getSubscriptions in interface org.cometd.bayeux.server.ServerSession
    • addExtension

      public void addExtension​(org.cometd.bayeux.server.ServerSession.Extension extension)
      Specified by:
      addExtension in interface org.cometd.bayeux.server.ServerSession
    • removeExtension

      public void removeExtension​(org.cometd.bayeux.server.ServerSession.Extension extension)
      Specified by:
      removeExtension in interface org.cometd.bayeux.server.ServerSession
    • getExtensions

      public java.util.List<org.cometd.bayeux.server.ServerSession.Extension> getExtensions()
      Specified by:
      getExtensions in interface org.cometd.bayeux.server.ServerSession
    • batch

      public void batch​(java.lang.Runnable batch)
      Specified by:
      batch in interface org.cometd.bayeux.Session
    • deliver

      public void deliver​(org.cometd.bayeux.Session sender, org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
      Specified by:
      deliver in interface org.cometd.bayeux.server.ServerSession
    • deliver

      public void deliver​(org.cometd.bayeux.Session sender, java.lang.String channelId, java.lang.Object data, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
      Specified by:
      deliver in interface org.cometd.bayeux.server.ServerSession
    • deliver1

      protected void deliver1​(org.cometd.bayeux.server.ServerSession sender, org.cometd.bayeux.server.ServerMessage.Mutable mutable, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
    • extendOutgoing

      protected void extendOutgoing​(org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<org.cometd.bayeux.server.ServerMessage.Mutable> promise)
    • handshake

      protected boolean handshake​(org.cometd.bayeux.server.ServerMessage.Mutable message)
    • connected

      protected boolean connected()
    • disconnect

      public void disconnect()
      Specified by:
      disconnect in interface org.cometd.bayeux.Session
    • startBatch

      public void startBatch()
      Specified by:
      startBatch in interface org.cometd.bayeux.Session
    • endBatch

      public boolean endBatch()
      Specified by:
      endBatch in interface org.cometd.bayeux.Session
    • getLocalSession

      public org.cometd.bayeux.server.LocalSession getLocalSession()
      Specified by:
      getLocalSession in interface org.cometd.bayeux.server.ServerSession
    • isLocalSession

      public boolean isLocalSession()
      Specified by:
      isLocalSession in interface org.cometd.bayeux.server.ServerSession
    • addListener

      public void addListener​(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)
      Specified by:
      addListener in interface org.cometd.bayeux.server.ServerSession
    • getId

      public java.lang.String getId()
      Specified by:
      getId in interface org.cometd.bayeux.Session
    • getLock

      public java.lang.Object getLock()
    • getQueue

      public java.util.Queue<org.cometd.bayeux.server.ServerMessage> getQueue()
    • hasNonLazyMessages

      public boolean hasNonLazyMessages()
    • addMessage

      protected void addMessage​(org.cometd.bayeux.server.ServerMessage message)
    • takeQueue

      public java.util.List<org.cometd.bayeux.server.ServerMessage> takeQueue​(java.util.List<org.cometd.bayeux.server.ServerMessage.Mutable> replies)
    • notifySuspended

      public void notifySuspended​(org.cometd.bayeux.server.ServerMessage message, long timeout)
    • notifyResumed

      public void notifyResumed​(org.cometd.bayeux.server.ServerMessage message, boolean timeout)
    • removeListener

      public void removeListener​(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)
      Specified by:
      removeListener in interface org.cometd.bayeux.server.ServerSession
    • getListeners

      public java.util.List<org.cometd.bayeux.server.ServerSession.ServerSessionListener> getListeners()
    • setScheduler

      public void setScheduler​(AbstractServerTransport.Scheduler newScheduler)
    • shouldSchedule

      public boolean shouldSchedule()
    • flush

      public void flush()
    • destroyScheduler

      public void destroyScheduler()
    • cancelExpiration

      public void cancelExpiration​(boolean metaConnect)
    • scheduleExpiration

      public void scheduleExpiration​(long defaultInterval, long defaultMaxInterval)
    • getMaxInterval

      public long getMaxInterval()
      Specified by:
      getMaxInterval in interface org.cometd.bayeux.server.ServerSession
    • setMaxInterval

      public void setMaxInterval​(long maxInterval)
      Specified by:
      setMaxInterval in interface org.cometd.bayeux.server.ServerSession
    • getAttribute

      public java.lang.Object getAttribute​(java.lang.String name)
      Specified by:
      getAttribute in interface org.cometd.bayeux.Session
    • getAttributeNames

      public java.util.Set<java.lang.String> getAttributeNames()
      Specified by:
      getAttributeNames in interface org.cometd.bayeux.Session
    • removeAttribute

      public java.lang.Object removeAttribute​(java.lang.String name)
      Specified by:
      removeAttribute in interface org.cometd.bayeux.Session
    • setAttribute

      public void setAttribute​(java.lang.String name, java.lang.Object value)
      Specified by:
      setAttribute in interface org.cometd.bayeux.Session
    • isHandshook

      public boolean isHandshook()
      Specified by:
      isHandshook in interface org.cometd.bayeux.Session
    • isConnected

      public boolean isConnected()
      Specified by:
      isConnected in interface org.cometd.bayeux.Session
    • isDisconnected

      public boolean isDisconnected()
    • isTerminated

      public boolean isTerminated()
    • extendIncoming

      protected void extendIncoming​(org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
    • reAdvise

      public void reAdvise()
    • takeAdvice

      public java.util.Map<java.lang.String,​java.lang.Object> takeAdvice​(org.cometd.bayeux.server.ServerTransport transport)
    • getServerTransport

      public org.cometd.bayeux.server.ServerTransport getServerTransport()
      Specified by:
      getServerTransport in interface org.cometd.bayeux.server.ServerSession
    • setServerTransport

      public void setServerTransport​(org.cometd.bayeux.server.ServerTransport transport)
    • getTimeout

      public long getTimeout()
      Specified by:
      getTimeout in interface org.cometd.bayeux.server.ServerSession
    • getInterval

      public long getInterval()
      Specified by:
      getInterval in interface org.cometd.bayeux.server.ServerSession
    • setTimeout

      public void setTimeout​(long timeoutMS)
      Specified by:
      setTimeout in interface org.cometd.bayeux.server.ServerSession
    • setInterval

      public void setInterval​(long intervalMS)
      Specified by:
      setInterval in interface org.cometd.bayeux.server.ServerSession
    • isBroadcastToPublisher

      public boolean isBroadcastToPublisher()
    • setBroadcastToPublisher

      public void setBroadcastToPublisher​(boolean value)
    • added

      protected void added()
    • removed

      protected boolean removed​(boolean timedOut)
      Parameters:
      timedOut - whether the session has been timed out
      Returns:
      True if the session was connected.
    • setMetaConnectDeliveryOnly

      public void setMetaConnectDeliveryOnly​(boolean meta)
    • isMetaConnectDeliveryOnly

      public boolean isMetaConnectDeliveryOnly()
    • isAllowMessageDeliveryDuringHandshake

      public boolean isAllowMessageDeliveryDuringHandshake()
    • setAllowMessageDeliveryDuringHandshake

      public void setAllowMessageDeliveryDuringHandshake​(boolean allow)
    • subscribe

      protected boolean subscribe​(ServerChannelImpl channel)
    • unsubscribedFrom

      protected void unsubscribedFrom​(ServerChannelImpl channel)
    • calculateTimeout

      public long calculateTimeout​(long defaultTimeout)
    • calculateInterval

      public long calculateInterval​(long defaultInterval)
    • updateTransientTimeout

      public void updateTransientTimeout​(long timeout)
      Updates the transient timeout with the given value. The transient timeout is the one sent by the client, that should temporarily override the session/transport timeout, for example when the client sends {timeout:0}
      Parameters:
      timeout - the value to update the timeout to
      See Also:
      updateTransientInterval(long)
    • updateTransientInterval

      public void updateTransientInterval​(long interval)
      Updates the transient interval with the given value. The transient interval is the one sent by the client, that should temporarily override the session/transport interval, for example when the client sends {timeout:0,interval:60000}
      Parameters:
      interval - the value to update the interval to
      See Also:
      updateTransientTimeout(long)
    • dump

      public void dump​(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Throws:
      java.io.IOException
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object