Class ServerSessionImpl

  • All Implemented Interfaces:
    ServerSession, Session, org.eclipse.jetty.util.component.Dumpable

    public class ServerSessionImpl
    extends java.lang.Object
    implements ServerSession, org.eclipse.jetty.util.component.Dumpable
    • Method Detail

      • getUserAgent

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

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

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

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

        Sets a remote client identifier, typically a browser.

        browserId - the remote client identifier
      • sweep

        protected void sweep​(long now)
      • batch

        public void batch​(java.lang.Runnable batch)
        Description copied from interface: Session

        Executes the given command in a batch so that any Bayeux message sent by the command (via the Bayeux API) is queued up until the end of the command and then all messages are sent at once.

        Specified by:
        batch in interface Session
        batch - the Runnable to run as a batch
      • deliver

        public void deliver​(Session sender,
                            java.lang.String channelId,
                            java.lang.Object data,
                            Promise<java.lang.Boolean> promise)
        Description copied from interface: ServerSession

        Delivers the given information to this session.

        Specified by:
        deliver in interface ServerSession
        sender - the session delivering the message
        channelId - the channel of the message
        data - the data of the message
        promise - the promise to notify with the result of the deliver
        See Also:
        ServerSession.deliver(Session, ServerMessage.Mutable, Promise)
      • connected

        protected boolean connected()
      • disconnect

        public void disconnect()
        Description copied from interface: Session
        Disconnects this session, ending the link between the client and the server peers.
        Specified by:
        disconnect in interface Session
        See Also:
      • isLocalSession

        public boolean isLocalSession()
        Specified by:
        isLocalSession in interface ServerSession
        whether this is a session for a local client on server-side
      • getId

        public java.lang.String getId()
        Description copied from interface: Session

        The clientId of the session.

        This would more correctly be called a "sessionId", but for backwards compatibility with the Bayeux protocol, it is a field called "clientId" that identifies a session.

        Specified by:
        getId in interface Session
        the id of this session
      • getLock

        public java.lang.Object getLock()
      • hasNonLazyMessages

        public boolean hasNonLazyMessages()
      • addMessage

        protected void addMessage​(ServerMessage message)
      • notifySuspended

        public void notifySuspended​(ServerMessage message,
                                    long timeout)
      • notifyResumed

        public void notifyResumed​(ServerMessage message,
                                  boolean timeout)
      • shouldSchedule

        public boolean shouldSchedule()
      • flush

        public void flush()
      • destroyScheduler

        public void destroyScheduler()
      • cancelExpiration

        public void cancelExpiration​(boolean metaConnect)
      • scheduleExpiration

        public void scheduleExpiration​(long defaultInterval)
      • getMaxInterval

        protected long getMaxInterval()
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Description copied from interface: Session

        Retrieves the value of named session attribute.

        Specified by:
        getAttribute in interface Session
        name - the name of the attribute
        the attribute value or null if the attribute is not present
      • getAttributeNames

        public java.util.Set<java.lang.String> getAttributeNames()
        Specified by:
        getAttributeNames in interface Session
        the list of session attribute names.
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.String name)
        Description copied from interface: Session

        Removes a named session attribute.

        Specified by:
        removeAttribute in interface Session
        name - the name of the attribute
        the value of the attribute
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.Object value)
        Description copied from interface: Session

        Sets a named session attribute value.

        Session attributes are convenience data that allows arbitrary application data to be associated with a session.

        Specified by:
        setAttribute in interface Session
        name - the attribute name
        value - the attribute value
      • isHandshook

        public boolean isHandshook()
        Description copied from interface: Session

        A handshook session is a session where the handshake has successfully completed

        Specified by:
        isHandshook in interface Session
        whether the session is handshook
      • isConnected

        public boolean isConnected()
        Description copied from interface: Session

        A connected session is a session where the link between the client and the server has been established.

        Specified by:
        isConnected in interface Session
        whether the session is connected
        See Also:
      • isDisconnected

        public boolean isDisconnected()
      • isTerminated

        public boolean isTerminated()
      • reAdvise

        public void reAdvise()
      • takeAdvice

        public java.util.Map<java.lang.String,​java.lang.Object> takeAdvice​(ServerTransport transport)
      • setServerTransport

        public void setServerTransport​(ServerTransport transport)
      • getTimeout

        public long getTimeout()
        Specified by:
        getTimeout in interface ServerSession
        the period of time, in milliseconds, that the server will hold connect messages for this session or -1 if the default value is used
        See Also:
      • setTimeout

        public void setTimeout​(long timeoutMS)
        Specified by:
        setTimeout in interface ServerSession
        timeoutMS - the period of time, in milliseconds, that the server will hold connect messages for this session
      • setInterval

        public void setInterval​(long intervalMS)
        Specified by:
        setInterval in interface ServerSession
        intervalMS - the period of time, in milliseconds, that the client associated with this session will wait before issuing a connect message
      • isBroadcastToPublisher

        public boolean isBroadcastToPublisher()
      • setBroadcastToPublisher

        public void setBroadcastToPublisher​(boolean value)
      • added

        protected void added()
      • removed

        protected boolean removed​(boolean timedOut)
        timedOut - whether the session has been timed out
        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)
      • 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}
        timeout - the value to update the timeout to
        See Also:
      • 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}
        interval - the value to update the interval to
        See Also:
      • dump

        public java.lang.String dump()
        Specified by:
        dump in interface org.eclipse.jetty.util.component.Dumpable
      • dump

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

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