public interface Session
extends java.io.Closeable
Modifier and Type | Method and Description |
---|---|
<T> void |
addMessageHandler(java.lang.Class<T> clazz,
MessageHandler.Partial<T> handler)
Registers a
MessageHandler for partial incoming messages. |
<T> void |
addMessageHandler(java.lang.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.
|
java.lang.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.
|
java.util.Set<MessageHandler> |
getMessageHandlers() |
java.util.List<Extension> |
getNegotiatedExtensions() |
java.lang.String |
getNegotiatedSubprotocol() |
java.util.Set<Session> |
getOpenSessions()
Obtain the set of open sessions associated with the same local endpoint
as this session.
|
java.util.Map<java.lang.String,java.lang.String> |
getPathParameters() |
java.lang.String |
getProtocolVersion() |
java.lang.String |
getQueryString() |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getRequestParameterMap() |
java.net.URI |
getRequestURI() |
java.security.Principal |
getUserPrincipal() |
java.util.Map<java.lang.String,java.lang.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 java.lang.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 messagejava.lang.IllegalStateException
- If a message handler has already been
registered for the associated message typejava.util.Set<MessageHandler> getMessageHandlers()
void removeMessageHandler(MessageHandler listener)
java.lang.String getProtocolVersion()
java.lang.String getNegotiatedSubprotocol()
java.util.List<Extension> getNegotiatedExtensions()
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()
java.lang.String getId()
void close() throws java.io.IOException
CloseReason.CloseCodes.NORMAL_CLOSURE
and an
empty reason phrase.close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException
- if an I/O error occurs while the WebSocket session is
being closed.void close(CloseReason closeReason) throws java.io.IOException
closeReason
- The reason the WebSocket session is being closed.java.io.IOException
- if an I/O error occurs while the WebSocket session is
being closed.java.net.URI getRequestURI()
java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestParameterMap()
java.lang.String getQueryString()
java.util.Map<java.lang.String,java.lang.String> getPathParameters()
java.util.Map<java.lang.String,java.lang.Object> getUserProperties()
java.security.Principal getUserPrincipal()
java.util.Set<Session> getOpenSessions()
<T> void addMessageHandler(java.lang.Class<T> clazz, MessageHandler.Partial<T> handler) throws java.lang.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 messagejava.lang.IllegalStateException
- If a message handler has already been
registered for the associated message type<T> void addMessageHandler(java.lang.Class<T> clazz, MessageHandler.Whole<T> handler) throws java.lang.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 messagejava.lang.IllegalStateException
- If a message handler has already been
registered for the associated message typeCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.