Class ServiceSession

  • All Implemented Interfaces:
    Session

    class ServiceSession
    extends java.lang.Object
    implements Session
    The ServiceSession represents a simple WebSocket session that contains the connection handshake details and the actual socket. In order to determine how the session should be interacted with the protocol is conveniently exposed, however all attributes of the original HTTP request are available.
    See Also:
    FrameChannel
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map attributes
      This is the bag of attributes used by this session.
      private FrameChannel channel
      The WebSocket used for asynchronous full duplex communication.
      private Request request
      This is the initiating request associated with the session.
      private Response response
      This is the initiating response associated with the session.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object getAttribute​(java.lang.Object key)
      This is used as a shortcut for acquiring attributes for the response.
      java.util.Map getAttributes()
      This can be used to retrieve the response attributes.
      FrameChannel getChannel()
      Provides a WebSocket that can be used to communicate with the connected client.
      Request getRequest()
      Provides the Request used to initiate the session.
      Response getResponse()
      Provides the Response used to establish the session with the remote client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • channel

        private final FrameChannel channel
        The WebSocket used for asynchronous full duplex communication.
      • response

        private final Response response
        This is the initiating response associated with the session.
      • request

        private final Request request
        This is the initiating request associated with the session.
      • attributes

        private final java.util.Map attributes
        This is the bag of attributes used by this session.
    • Constructor Detail

      • ServiceSession

        public ServiceSession​(FrameChannel channel,
                              Request request,
                              Response response)
        Constructor for the ServiceSession object. This is used to create the session that will be used by a Service to send and receive WebSocket frames.
        Parameters:
        channel - this is the actual WebSocket for the session
        request - this is the session initiating request
        response - this is the session initiating response
    • Method Detail

      • getAttributes

        public java.util.Map getAttributes()
        This can be used to retrieve the response attributes. These can be used to keep state with the response when it is passed to other systems for processing. Attributes act as a convenient model for storing objects associated with the response. This also inherits attributes associated with the client connection.
        Specified by:
        getAttributes in interface Session
        Returns:
        the attributes of that have been set on the request
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.Object key)
        This is used as a shortcut for acquiring attributes for the response. This avoids acquiring the attribute Map in order to retrieve the attribute directly from that object. The attributes contain data specific to the response.
        Specified by:
        getAttribute in interface Session
        Parameters:
        key - this is the key of the attribute to acquire
        Returns:
        this returns the attribute for the specified name
      • getChannel

        public FrameChannel getChannel()
        Provides a WebSocket that can be used to communicate with the connected client. Communication is full duplex and also asynchronous through the use of a FrameListener that can be registered with the socket.
        Specified by:
        getChannel in interface Session
        Returns:
        a web socket for full duplex communication
      • getRequest

        public Request getRequest()
        Provides the Request used to initiate the session. This is useful in establishing the identity of the user, acquiring an security information and also for determining the request path that was used, which be used to establish context.
        Specified by:
        getRequest in interface Session
        Returns:
        the request used to initiate the session
      • getResponse

        public Response getResponse()
        Provides the Response used to establish the session with the remote client. This is useful in establishing the protocol used to create the session and also for determining various other useful contextual information.
        Specified by:
        getResponse in interface Session
        Returns:
        the response used to establish the session