Interface Session

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void batch​(java.lang.Runnable batch)
      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.
      void disconnect()
      Disconnects this session, ending the link between the client and the server peers.
      boolean endBatch()
      Ends a batch started with startBatch().
      java.lang.Object getAttribute​(java.lang.String name)
      Retrieves the value of named session attribute.
      java.util.Set<java.lang.String> getAttributeNames()  
      java.lang.String getId()
      The clientId of the session.
      boolean isConnected()
      A connected session is a session where the link between the client and the server has been established.
      boolean isHandshook()
      A handshook session is a session where the handshake has successfully completed
      java.lang.Object removeAttribute​(java.lang.String name)
      Removes a named session attribute.
      void setAttribute​(java.lang.String name, java.lang.Object value)
      Sets a named session attribute value.
      void startBatch()
      Starts a batch, to be ended with endBatch().
    • Method Detail

      • getId

        java.lang.String getId()

        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.

        Returns:
        the id of this session
      • isConnected

        boolean isConnected()

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

        Returns:
        whether the session is connected
        See Also:
        disconnect()
      • isHandshook

        boolean isHandshook()

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

        Returns:
        whether the session is handshook
      • disconnect

        void disconnect()
        Disconnects this session, ending the link between the client and the server peers.
        See Also:
        isConnected()
      • setAttribute

        void setAttribute​(java.lang.String name,
                          java.lang.Object value)

        Sets a named session attribute value.

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

        Parameters:
        name - the attribute name
        value - the attribute value
      • getAttribute

        java.lang.Object getAttribute​(java.lang.String name)

        Retrieves the value of named session attribute.

        Parameters:
        name - the name of the attribute
        Returns:
        the attribute value or null if the attribute is not present
      • getAttributeNames

        java.util.Set<java.lang.String> getAttributeNames()
        Returns:
        the list of session attribute names.
      • removeAttribute

        java.lang.Object removeAttribute​(java.lang.String name)

        Removes a named session attribute.

        Parameters:
        name - the name of the attribute
        Returns:
        the value of the attribute
      • batch

        void batch​(java.lang.Runnable batch)

        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.

        Parameters:
        batch - the Runnable to run as a batch
      • startBatch

        void startBatch()

        Starts a batch, to be ended with endBatch().

        The batch(Runnable) method should be preferred since it automatically starts and ends a batch without relying on a try/finally block.

        This method is to be used in the cases where the use of batch(Runnable) is not possible or would make the code more complex.

        See Also:
        endBatch(), batch(Runnable)
      • endBatch

        boolean endBatch()

        Ends a batch started with startBatch().

        Returns:
        true if the batch ended and there were messages to send.
        See Also:
        startBatch()