Top Description Inners Fields Constructors Methods
org.glassfish.tyrus.core

public Class TyrusSession

extends Object
implements DistributedSession
Class Inheritance
All Implemented Interfaces
org.glassfish.tyrus.core.cluster.DistributedSession, jakarta.websocket.Session, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, java.net.URI, .URISyntaxException, java.nio.ByteBuffer, java.nio.charset.Charset, java.security.Principal, java.util.Collections, .HashMap, .HashSet, .List, .Map, .Set, .UUID, .Map.Entry, java.util.concurrent.Future, .ScheduledExecutorService, .ScheduledFuture, .TimeUnit, java.util.concurrent.atomic.AtomicReference, java.util.concurrent.locks.ReentrantLock, java.util.logging.Level, .Logger, jakarta.websocket.CloseReason, .DecodeException, .Decoder, .Extension, .MessageHandler, .PongMessage, .Session, .WebSocketContainer, org.glassfish.tyrus.core.cluster.ClusterContext, .DistributedSession, .RemoteSession, .SessionEventListener, org.glassfish.tyrus.core.coder.CoderWrapper, org.glassfish.tyrus.core.l10n.LocalizationMessages

Implementation of the Session.
Authors
Danny Coward, Stepan Kopriva, Martin Matula, Pavel Bucek

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
pack-priv static enum
TyrusSession.State

Session state.

Field Summary

Modifier and TypeField and Description
private final TyrusRemoteEndpoint.Async
private final TyrusRemoteEndpoint.Basic
private final BinaryBuffer
private final String
private final WebSocketContainer
private final DebugContext
private final Map<RemoteSession.DistributedMapKey, Object>
private final Map<String, Object>
private final TyrusEndpointWrapper
private final MessageHandlerManager
private final ReentrantLock
private volatile long
private volatile ScheduledFuture<?>
private final String
private volatile ScheduledFuture<?>
private final ReentrantLock
private InputStreamBuffer
private final boolean
private static final Logger
private int
private volatile long
private int
private final List<Extension>
private final String
private final Map<String, String>
private final String
private ReaderBuffer
private final String
private final Map<String, List<String>>
private final URI
private final String
private final int
private ScheduledExecutorService
private final AtomicReference<TyrusSession.State>
private final TextBuffer
private final Principal
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
pack-priv
TyrusSession(WebSocketContainer container, TyrusWebSocket socket, TyrusEndpointWrapper endpointWrapper, String subprotocol, List<Extension> extensions, boolean isSecure, URI requestURI, String queryString, Map<String, String> pathParameters, Principal principal, Map<String, List<String>> requestParameterMap, final ClusterContext clusterContext, String connectionId, final String remoteAddr, String serverAddr, final int serverPort, TyrusConfiguration tyrusConfiguration, DebugContext debugContext)

Method Summary

Modifier and TypeMethod and Description
public void
addMessageHandler(MessageHandler
the MessageHandler to be added.
handler
)

Implements jakarta.websocket.Session.addMessageHandler.

Register to handle to incoming messages in this conversation.

public <T> void
addMessageHandler(Class<T>
type of the message processed by message handler to be registered.
clazz
,
MessageHandler.Whole<T>
the MessageHandler to be added.
handler
)

Implements jakarta.websocket.Session.addMessageHandler.

Register to handle to incoming messages in this conversation.

public <T> void
addMessageHandler(Class<T>
type of the message processed by message handler to be registered.
clazz
,
MessageHandler.Partial<T>
the MessageHandler to be added.
handler
)

Implements jakarta.websocket.Session.addMessageHandler.

Register to handle to incoming messages in this conversation.

public Map<Session, Future<?>>

Returns:

map of local sessions and futures for user to get the information about status of the message.
broadcast
(String
message to be broadcasted.
message
)

Broadcasts text message to all connected clients.

public Map<Session, Future<?>>

Returns:

map of local sessions and futures for user to get the information about status of the message.
broadcast
(ByteBuffer
message to be broadcasted.
message
)

Broadcasts binary message to all connected clients, including remote sessions (if any).

private void
private void
private void
private void
private void
checkMessageSize(Object message, long maxMessageSize)

private void
public void
close()

Implements jakarta.websocket.Session.close.

Close the current conversation with a normal status code and no reason phrase.

public void
close(CloseReason
the reason for the closure.
closeReason
)

Implements jakarta.websocket.Session.close.

Close the current conversation, giving a reason for the closure.

private static void
public Set<DistributedSession>

Returns:

set of distributed sessions.
getAllSessions
()

Get set of all sessions opened to the same endpoint.

public RemoteEndpoint.Async
getAsyncRemote()

Implements jakarta.websocket.Session.getAsyncRemote.

Return a reference a RemoteEndpoint object representing the peer of this conversation that is able to send messages asynchronously to the peer.

public RemoteEndpoint.Basic
getBasicRemote()

Implements jakarta.websocket.Session.getBasicRemote.

Return a reference a RemoteEndpoint object representing the peer of this conversation that is able to send messages synchronously to the peer.

pack-priv BinaryBuffer
pack-priv String
public WebSocketContainer
getContainer()

Implements jakarta.websocket.Session.getContainer.

Return the container that this session is part of.

pack-priv DebugContext
public Map<String, Object>
public long

Returns:

heartbeatInterval interval between periodic pong messages in milliseconds.
getHeartbeatInterval
()

Return an interval in milliseconds between scheduled periodic Pong messages.

public String
getId()

Implements jakarta.websocket.Session.getId.

Returns a string containing the unique identifier assigned to this session.

pack-priv InputStreamBuffer
public int
getMaxBinaryMessageBufferSize()

Implements jakarta.websocket.Session.getMaxBinaryMessageBufferSize.

The maximum length of incoming binary messages that this Session can buffer.

public long
getMaxIdleTimeout()

Implements jakarta.websocket.Session.getMaxIdleTimeout.

Return the number of milliseconds before this session will be closed by the container if it is inactive, i.e. no messages are either sent or received in that time.

public int
getMaxTextMessageBufferSize()

Implements jakarta.websocket.Session.getMaxTextMessageBufferSize.

The maximum length of incoming text messages that this Session can buffer.

pack-priv <T> MessageHandler.Whole<T>
public Set<MessageHandler>
getMessageHandlers()

Implements jakarta.websocket.Session.getMessageHandlers.

Return an unmodifiable copy of the set of MessageHandlers for this Session.

public List<Extension>
getNegotiatedExtensions()

Implements jakarta.websocket.Session.getNegotiatedExtensions.

Return the list of extensions currently in use for this conversation.

public String
getNegotiatedSubprotocol()

Implements jakarta.websocket.Session.getNegotiatedSubprotocol.

Return the sub protocol agreed during the websocket handshake for this conversation.

public Set<Session>
getOpenSessions()

Implements jakarta.websocket.Session.getOpenSessions.

Return a copy of the Set of all the open web socket sessions that represent connections to the same endpoint to which this session represents a connection.

public Map<String, String>
getPathParameters()

Implements jakarta.websocket.Session.getPathParameters.

Return a map of the path parameter names and values used associated with the request this session was opened under.

public String
getProtocolVersion()

Implements jakarta.websocket.Session.getProtocolVersion.

Returns the version of the websocket protocol currently being used.

public String
getQueryString()

Implements jakarta.websocket.Session.getQueryString.

Return the query string associated with the request this session was opened under.

pack-priv ReaderBuffer
public String

Returns:

a String containing the IP address of the client that sent the request or null when method is called on client-side.
getRemoteAddr
()

Get the Internet Protocol (IP) address of the client or last proxy that sent the request.

public Set<RemoteSession>

Returns:

set of remote sessions or empty set, when not running in cluster environment.
getRemoteSessions
()

Get set of remote sessions.

public Map<String, List<String>>
getRequestParameterMap()

Implements jakarta.websocket.Session.getRequestParameterMap.

Return the request parameters associated with the request this session was opened under.

public URI
getRequestURI()

Implements jakarta.websocket.Session.getRequestURI.

Return the complete URI under which this session was opened, from protocol to query string (if present).

pack-priv TyrusSession.State
pack-priv TextBuffer
public Principal
getUserPrincipal()

Implements jakarta.websocket.Session.getUserPrincipal.

Return the authenticated user for this Session or null if no user is authenticated for this session.

public Map<String, Object>
getUserProperties()

Implements jakarta.websocket.Session.getUserProperties.

While the session is open, this method returns a Map that the developer may use to store application specific information relating to this session instance.

pack-priv boolean
public boolean
isOpen()

Implements jakarta.websocket.Session.isOpen.

Return true if and only if the underlying socket is open.

pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
public boolean
isSecure()

Implements jakarta.websocket.Session.isSecure.

Return true if and only if the underlying socket is using a secure transport.

pack-priv boolean
pack-priv boolean
pack-priv void
notifyMessageHandlers(Object message, List<CoderWrapper<Decoder>> availableDecoders)

pack-priv void
notifyMessageHandlers(Object message, boolean last)

pack-priv void
public void
removeMessageHandler(MessageHandler
the handler to be removed.
handler
)

Implements jakarta.websocket.Session.removeMessageHandler.

Remove the given MessageHandler from the set belonging to this session.

pack-priv void
public void
setHeartbeatInterval(long
interval between periodic Pong messages in milliseconds.
heartbeatInterval
)

Set an interval in milliseconds between scheduled periodic Pong messages.

pack-priv void
public void
setMaxBinaryMessageBufferSize(int
the maximum length.
maxBinaryMessageBufferSize
)

Implements jakarta.websocket.Session.setMaxBinaryMessageBufferSize.

Sets the maximum length of incoming binary messages that this Session can buffer.

public void
setMaxIdleTimeout(long
the number of milliseconds.
maxIdleTimeout
)

Implements jakarta.websocket.Session.setMaxIdleTimeout.

Set the number of milliseconds before this session will be closed by the container if it is inactive, i.e. no messages are either sent or received in that time.

public void
setMaxTextMessageBufferSize(int
the maximum length.
maxTextMessageBufferSize
)

Implements jakarta.websocket.Session.setMaxTextMessageBufferSize.

Sets the maximum length of incoming text messages that this Session can buffer.

pack-priv void
pack-priv void
setState(TyrusSession.State
the newly set state.
state
)

Set the state of the Session.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait