public interface Session extends Closeable
Modifier and Type | Method and Description |
---|---|
<T> void |
addMessageHandler(Class<T> clazz,
MessageHandler.Partial<T> handler)
Registers a
MessageHandler for partial incoming messages. |
<T> void |
addMessageHandler(Class<T> clazz,
MessageHandler.Whole<T> handler)
Registers a
MessageHandler for whole incoming messages. |
void |
addMessageHandler(MessageHandler handler)
Registers a
MessageHandler for incoming messages. |
void |
close()
Close the connection to the remote end point using the code
CloseReason.CloseCodes.NORMAL_CLOSURE and an
empty reason phrase. |
void |
close(CloseReason closeReason)
Close the connection to the remote end point using the specified code
and reason phrase.
|
RemoteEndpoint.Async |
getAsyncRemote() |
RemoteEndpoint.Basic |
getBasicRemote() |
WebSocketContainer |
getContainer()
Get the container that created this session.
|
String |
getId()
Provides a unique identifier for the session.
|
int |
getMaxBinaryMessageBufferSize()
Get the current maximum buffer size for binary messages.
|
long |
getMaxIdleTimeout()
Get the idle timeout for this session.
|
int |
getMaxTextMessageBufferSize()
Get the maximum buffer size for text messages.
|
Set<MessageHandler> |
getMessageHandlers() |
List<Extension> |
getNegotiatedExtensions() |
String |
getNegotiatedSubprotocol() |
Set<Session> |
getOpenSessions()
Obtain the set of open sessions associated with the same local endpoint
as this session.
|
Map<String,String> |
getPathParameters() |
String |
getProtocolVersion() |
String |
getQueryString() |
Map<String,List<String>> |
getRequestParameterMap() |
URI |
getRequestURI() |
Principal |
getUserPrincipal() |
Map<String,Object> |
getUserProperties() |
boolean |
isOpen() |
boolean |
isSecure() |
void |
removeMessageHandler(MessageHandler listener) |
void |
setMaxBinaryMessageBufferSize(int max)
Set the current maximum buffer size for binary messages.
|
void |
setMaxIdleTimeout(long timeout)
Set the idle timeout for this session.
|
void |
setMaxTextMessageBufferSize(int max)
Set the maximum buffer size for text messages.
|
WebSocketContainer getContainer()
void addMessageHandler(MessageHandler handler) throws IllegalStateException
MessageHandler
for incoming messages. Only one
MessageHandler
may be registered for each message type (text,
binary, pong). The message type will be derived at runtime from the
provided MessageHandler
instance. It is not always possible to do
this so it is better to use
addMessageHandler(Class, javax.websocket.MessageHandler.Partial)
or
addMessageHandler(Class, javax.websocket.MessageHandler.Whole)
.handler
- The message handler for a incoming messageIllegalStateException
- If a message handler has already been
registered for the associated message typeSet<MessageHandler> getMessageHandlers()
void removeMessageHandler(MessageHandler listener)
String getProtocolVersion()
String getNegotiatedSubprotocol()
boolean isSecure()
boolean isOpen()
long getMaxIdleTimeout()
void setMaxIdleTimeout(long timeout)
timeout
- The new idle timeout for this session in milliseconds.
Zero or negative values indicate an infinite timeout.void setMaxBinaryMessageBufferSize(int max)
max
- The new maximum buffer size in bytesint getMaxBinaryMessageBufferSize()
void setMaxTextMessageBufferSize(int max)
max
- The new maximum buffer size in characters.int getMaxTextMessageBufferSize()
RemoteEndpoint.Async getAsyncRemote()
RemoteEndpoint.Basic getBasicRemote()
String getId()
void close() throws IOException
CloseReason.CloseCodes.NORMAL_CLOSURE
and an
empty reason phrase.close
in interface AutoCloseable
close
in interface Closeable
IOException
- if an I/O error occurs while the WebSocket session is
being closed.void close(CloseReason closeReason) throws IOException
closeReason
- The reason the WebSocket session is being closed.IOException
- if an I/O error occurs while the WebSocket session is
being closed.URI getRequestURI()
String getQueryString()
Principal getUserPrincipal()
Set<Session> getOpenSessions()
<T> void addMessageHandler(Class<T> clazz, MessageHandler.Partial<T> handler) throws IllegalStateException
MessageHandler
for partial incoming messages. Only
one MessageHandler
may be registered for each message type (text
or binary, pong messages are never presented as partial messages).T
- The type of message that the given handler is intended
forclazz
- The Class that implements Thandler
- The message handler for a incoming messageIllegalStateException
- If a message handler has already been
registered for the associated message type<T> void addMessageHandler(Class<T> clazz, MessageHandler.Whole<T> handler) throws IllegalStateException
MessageHandler
for whole incoming messages. Only
one MessageHandler
may be registered for each message type (text,
binary, pong).T
- The type of message that the given handler is intended
forclazz
- The Class that implements Thandler
- The message handler for a incoming messageIllegalStateException
- If a message handler has already been
registered for the associated message typeCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.