Class ServiceSession
- java.lang.Object
-
- org.simpleframework.http.socket.service.ServiceSession
-
- All Implemented Interfaces:
Session
class ServiceSession extends java.lang.Object implements Session
TheServiceSession
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.
-
Constructor Summary
Constructors Constructor Description ServiceSession(FrameChannel channel, Request request, Response response)
Constructor for theServiceSession
object.
-
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 aWebSocket
that can be used to communicate with the connected client.Request
getRequest()
Provides theRequest
used to initiate the session.Response
getResponse()
Provides theResponse
used to establish the session with the remote client.
-
-
-
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 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 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 interfaceSession
- 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 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
public FrameChannel 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
public Request 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
public Response 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
-
-