Class ServiceSession
java.lang.Object
org.simpleframework.http.socket.service.ServiceSession
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
This is the bag of attributes used by this session.private final FrameChannel
The WebSocket used for asynchronous full duplex communication.private final Request
This is the initiating request associated with the session.private final Response
This is the initiating response associated with the session. -
Constructor Summary
ConstructorsConstructorDescriptionServiceSession
(FrameChannel channel, Request request, Response response) Constructor for theServiceSession
object. -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute
(Object key) This is used as a shortcut for acquiring attributes for the response.This can be used to retrieve the response attributes.Provides aWebSocket
that can be used to communicate with the connected client.Provides theRequest
used to initiate the session.Provides theResponse
used to establish the session with the remote client.
-
Field Details
-
channel
The WebSocket used for asynchronous full duplex communication. -
response
This is the initiating response associated with the session. -
request
This is the initiating request associated with the session. -
attributes
This is the bag of attributes used by this session.
-
-
Constructor Details
-
ServiceSession
Constructor for theServiceSession
object. This is used to create the session that will be used by aService
to send and receive WebSocket frames.- Parameters:
channel
- this is the actual WebSocket for the sessionrequest
- this is the session initiating requestresponse
- this is the session initiating response
-
-
Method Details
-
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 interfaceSession
- Returns:
- the attributes of that have been set on the request
-
getAttribute
This is used as a shortcut for acquiring attributes for the response. This avoids acquiring the attributeMap
in order to retrieve the attribute directly from that object. The attributes contain data specific to the response.- Specified by:
getAttribute
in interfaceSession
- Parameters:
key
- this is the key of the attribute to acquire- Returns:
- this returns the attribute for the specified name
-
getChannel
Provides aWebSocket
that can be used to communicate with the connected client. Communication is full duplex and also asynchronous through the use of aFrameListener
that can be registered with the socket.- Specified by:
getChannel
in interfaceSession
- Returns:
- a web socket for full duplex communication
-
getRequest
Provides theRequest
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 interfaceSession
- Returns:
- the request used to initiate the session
-
getResponse
Provides theResponse
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 interfaceSession
- Returns:
- the response used to establish the session
-