Package org.glassfish.tyrus.core.cluster
Class RemoteSession
java.lang.Object
org.glassfish.tyrus.core.cluster.RemoteSession
- All Implemented Interfaces:
Session
,Closeable
,AutoCloseable
,DistributedSession
Remote session represents session originating from another node.
- Author:
- Pavel Bucek
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionRemoteSession
(String sessionId, ClusterContext clusterContext, Map<RemoteSession.DistributedMapKey, Object> distributedPropertyMap, TyrusEndpointWrapper endpointWrapper, Session session) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessageHandler
(MessageHandler handler) This method is not supported onRemoteSession
.<T> void
addMessageHandler
(Class<T> clazz, MessageHandler.Partial<T> handler) This method is not supported onRemoteSession
.<T> void
addMessageHandler
(Class<T> clazz, MessageHandler.Whole<T> handler) This method is not supported onRemoteSession
.void
close()
Close the current conversation with a normal status code and no reason phrase.void
close
(CloseReason closeReason) Close the current conversation, giving a reason for the closure.Get a reference aRemoteEndpoint.Async
object representing the peer of this conversation that is able to send messages asynchronously to the peer.Get a reference aRemoteEndpoint.Basic
object representing the peer of this conversation that is able to send messages synchronously to the peer.This method is not supported onRemoteSession
.Get distributed properties.getId()
Get a string containing the unique identifier assigned to this session.int
Get the maximum length of incoming binary messages that this Session can buffer.long
Get the number of milliseconds before this conversation may be closed by the container if it is inactive, i.e. no messages are either sent or received in that time.int
Get the maximum length of incoming text messages that this Session can buffer.This method is not supported onRemoteSession
.Get the list of extensions currently in use for this conversation.Get the sub protocol agreed during the websocket handshake for this conversation.This method is not supported onRemoteSession
.Get a map of the path parameter names and values used associated with the request this session was opened under.Get the version of the websocket protocol currently being used.Get the query string associated with the request this session was opened under.Get the request parameters associated with the request this session was opened under.Get theURI
under which this session was opened, including the query string if there is one.Get the authenticated user for this session ornull
if no user is authenticated for this session.This method is not supported onRemoteSession
.boolean
isOpen()
Get the information about session state.boolean
isSecure()
Get the information about secure transport.void
removeMessageHandler
(MessageHandler handler) This method is not supported onRemoteSession
.void
setMaxBinaryMessageBufferSize
(int length) This method is not supported onRemoteSession
.void
setMaxIdleTimeout
(long milliseconds) This method is not supported onRemoteSession
.void
setMaxTextMessageBufferSize
(int length) This method is not supported onRemoteSession
.toString()
-
Constructor Details
-
RemoteSession
public RemoteSession(String sessionId, ClusterContext clusterContext, Map<RemoteSession.DistributedMapKey, Object> distributedPropertyMap, TyrusEndpointWrapper endpointWrapper, Session session) Constructor.- Parameters:
sessionId
- session id.clusterContext
- cluster context.distributedPropertyMap
- distributed property map.endpointWrapper
- used just to get encoders/decoders.session
- used just to get encoders/decoders.
-
-
Method Details
-
getProtocolVersion
Get the version of the websocket protocol currently being used. This is taken as the value of the Sec-WebSocket-Version header used in the opening handshake. i.e. "13".- Specified by:
getProtocolVersion
in interfaceSession
- Returns:
- the protocol version.
-
getNegotiatedSubprotocol
Get the sub protocol agreed during the websocket handshake for this conversation.- Specified by:
getNegotiatedSubprotocol
in interfaceSession
- Returns:
- the negotiated subprotocol, or the empty string if there isn't one.
-
getNegotiatedExtensions
Get the list of extensions currently in use for this conversation.- Specified by:
getNegotiatedExtensions
in interfaceSession
- Returns:
- the negotiated extensions.
-
isSecure
public boolean isSecure()Get the information about secure transport. -
isOpen
public boolean isOpen()Get the information about session state. -
getMaxIdleTimeout
public long getMaxIdleTimeout()Get the number of milliseconds before this conversation may be closed by the container if it is inactive, i.e. no messages are either sent or received in that time.- Specified by:
getMaxIdleTimeout
in interfaceSession
- Returns:
- the timeout in milliseconds.
-
getMaxBinaryMessageBufferSize
public int getMaxBinaryMessageBufferSize()Get the maximum length of incoming binary messages that this Session can buffer. If the implementation receives a binary message that it cannot buffer because it is too large, it must close the session with a close code ofCloseReason.CloseCodes.TOO_BIG
.- Specified by:
getMaxBinaryMessageBufferSize
in interfaceSession
- Returns:
- the maximum binary message size that can be buffered.
-
getMaxTextMessageBufferSize
public int getMaxTextMessageBufferSize()Get the maximum length of incoming text messages that this Session can buffer. If the implementation receives a text message that it cannot buffer because it is too large, it must close the session with a close code ofCloseReason.CloseCodes.TOO_BIG
.- Specified by:
getMaxTextMessageBufferSize
in interfaceSession
- Returns:
- the maximum text message size that can be buffered.
-
getAsyncRemote
Get a reference aRemoteEndpoint.Async
object representing the peer of this conversation that is able to send messages asynchronously to the peer.- Specified by:
getAsyncRemote
in interfaceSession
- Returns:
- the remote endpoint representation.
-
getBasicRemote
Get a reference aRemoteEndpoint.Basic
object representing the peer of this conversation that is able to send messages synchronously to the peer.- Specified by:
getBasicRemote
in interfaceSession
- Returns:
- the remote endpoint representation.
-
getId
Get a string containing the unique identifier assigned to this session. The identifier is assigned by the web socket implementation and is implementation dependent. -
close
Close the current conversation with a normal status code and no reason phrase.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSession
- Throws:
IOException
- if there was a connection error closing the connection.
-
close
Close the current conversation, giving a reason for the closure. The close call causes the implementation to attempt notify the client of the close as soon as it can. This may cause the sending of unsent messages immediately prior to the close notification. After the close notification has been sent the implementation notifies the endpoint's onClose method. Note the websocket specification defines the acceptable uses of status codes and reason phrases. If the application cannot determine a suitable close code to use for the closeReason, it is recommended to useCloseReason.CloseCodes.NO_STATUS_CODE
.- Specified by:
close
in interfaceSession
- Parameters:
closeReason
- the reason for the closure.- Throws:
IOException
- if there was a connection error closing the connection.
-
getRequestURI
Get theURI
under which this session was opened, including the query string if there is one.- Specified by:
getRequestURI
in interfaceSession
- Returns:
- the request URI.
-
getRequestParameterMap
Get the request parameters associated with the request this session was opened under.- Specified by:
getRequestParameterMap
in interfaceSession
- Returns:
- the unmodifiable map of the request parameters.
-
getQueryString
Get the query string associated with the request this session was opened under.- Specified by:
getQueryString
in interfaceSession
- Returns:
- the query string.
-
getPathParameters
Get a map of the path parameter names and values used associated with the request this session was opened under.- Specified by:
getPathParameters
in interfaceSession
- Returns:
- the unmodifiable map of path parameters. The key of the map is the parameter name, the values in the map are the parameter values.
-
getUserProperties
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
getUserProperties
in interfaceSession
- Returns:
- nothing.
- See Also:
-
getDistributedProperties
Description copied from interface:DistributedSession
Get distributed properties.Values put into this map must be
Serializable
or serializable by other, implementation-dependent alternative.Content of this map is synchronized among all cluster nodes, so putting an entry on any of the nodes will be visible on all other nodes which have reference to current session (in form of
TyrusSession
orRemoteSession
).Please note that when not running in the distributed environment, this map behaves similarly to
Session.getUserProperties()
, so no serialization or deserialization is performed when values are read from or stored to the returned map.- Specified by:
getDistributedProperties
in interfaceDistributedSession
- Returns:
- map of distributed properties.
- See Also:
-
getUserPrincipal
Get the authenticated user for this session ornull
if no user is authenticated for this session.- Specified by:
getUserPrincipal
in interfaceSession
- Returns:
- the user principal.
-
toString
-
getContainer
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
getContainer
in interfaceSession
- Returns:
- nothing.
-
addMessageHandler
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
addMessageHandler
in interfaceSession
- Parameters:
handler
- nothing.- Throws:
IllegalStateException
- if there is already a MessageHandler registered for the same native websocket message type as this handler.
-
addMessageHandler
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
addMessageHandler
in interfaceSession
- Type Parameters:
T
- type of message that the given handler is intended for.- Parameters:
clazz
- nothing.handler
- nothing.
-
addMessageHandler
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
addMessageHandler
in interfaceSession
- Type Parameters:
T
- type of message that the given handler is intended for.- Parameters:
clazz
- nothing.handler
- nothing.
-
getMessageHandlers
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
getMessageHandlers
in interfaceSession
- Returns:
- nothing.
-
removeMessageHandler
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
removeMessageHandler
in interfaceSession
- Parameters:
handler
- nothing.
-
setMaxIdleTimeout
public void setMaxIdleTimeout(long milliseconds) This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
setMaxIdleTimeout
in interfaceSession
- Parameters:
milliseconds
- nothing.
-
setMaxBinaryMessageBufferSize
public void setMaxBinaryMessageBufferSize(int length) This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
setMaxBinaryMessageBufferSize
in interfaceSession
- Parameters:
length
- nothing.
-
setMaxTextMessageBufferSize
public void setMaxTextMessageBufferSize(int length) This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
setMaxTextMessageBufferSize
in interfaceSession
- Parameters:
length
- nothing.
-
getOpenSessions
This method is not supported onRemoteSession
. Each invocation will throw anUnsupportedOperationException
.- Specified by:
getOpenSessions
in interfaceSession
- Returns:
- nothing.
-