|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Session
A Web Socket session represents a conversation between two web socket endpoints. As soon
as the websocket handshake completes successfully, the web socket implementation provides
the endpoint an open websocket session. The endpoint can then register interest in incoming
messages that are part of this newly created session by providing a MessageHandler to the
session, and can send messages to the other end of the conversation by means of the RemoteEndpoint object
obtained from this session.
IllegalStateException
being thrown.
Developers should retrieve any information from the session during the
Endpoint.onClose(javax.websocket.Session, javax.websocket.CloseReason)
method.
Method Summary | |
---|---|
void |
addMessageHandler(MessageHandler handler)
Register to handle to incoming messages in this conversation. |
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. |
WebSocketContainer |
getContainer()
Return the container that this session is part of. |
String |
getId()
Returns a string containing the unique identifier assigned to this session. |
int |
getMaxBinaryMessageBufferSize()
The maximum length of incoming binary messages that this Session can buffer. |
int |
getMaxTextMessageBufferSize()
The maximum length of incoming text messages that this Session can buffer. |
Set<MessageHandler> |
getMessageHandlers()
Return an unmodifiable copy of the set of MessageHandlers for this Session. |
List<Extension> |
getNegotiatedExtensions()
Return the list of extensions currently in use for this conversation. |
String |
getNegotiatedSubprotocol()
Return the sub protocol agreed during the websocket handshake for this conversation. |
Set<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. |
Map<String,String> |
getPathParameters()
Return a map of the path parameter names and values used associated with the request this session was opened under. |
String |
getProtocolVersion()
Returns the version of the websocket protocol currently being used. |
String |
getQueryString()
Return the query string associated with the request this session was opened under. |
RemoteEndpoint |
getRemote()
Return a reference to the RemoteEndpoint object representing the other end of this conversation. |
Map<String,List<String>> |
getRequestParameterMap()
Return the request parameters associated with the request this session was opened under. |
URI |
getRequestURI()
Return the URI under which this session was opened. |
long |
getTimeout()
Return the number of milliseconds before this conversation may be closed by the container if it is inactive, ie no messages are either sent or received in that time. |
Principal |
getUserPrincipal()
Return the authenticated user for this Session or null if no user is authenticated for this session. |
Map<String,Object> |
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. |
boolean |
isOpen()
Return true if and only if the underlying socket is open. |
boolean |
isSecure()
Return true if and only if the underlying socket is using a secure transport. |
void |
removeMessageHandler(MessageHandler handler)
Remove the given MessageHandler from the set belonging to this session. |
void |
setMaxBinaryMessageBufferSize(int length)
Sets the maximum length of incoming binary messages that this Session can buffer. |
void |
setMaxTextMessageBufferSize(int length)
Sets the maximum length of incoming text messages that this Session can buffer. |
void |
setTimeout(long milliseconds)
Set the non-zero number of milliseconds before this conversation will be closed by the container if it is inactive, ie no messages are either sent or received. |
Method Detail |
---|
WebSocketContainer getContainer()
void addMessageHandler(MessageHandler handler) throws IllegalStateException
MessageHandler.Basic
and MessageHandler.Async
.
Adding more than one of any one type will result in a runtime exception.
handler
- the MessageHandler to be added.
IllegalStateException
- if there is already a MessageHandler registered for the same native
websocket message type as this handler.Set<MessageHandler> getMessageHandlers()
void removeMessageHandler(MessageHandler handler)
handler
- the handler to be removed.String getProtocolVersion()
String getNegotiatedSubprotocol()
List<Extension> getNegotiatedExtensions()
boolean isSecure()
boolean isOpen()
long getTimeout()
void setTimeout(long milliseconds)
milliseconds
- the number of milliseconds.void setMaxBinaryMessageBufferSize(int length)
length
- the maximum length.int getMaxBinaryMessageBufferSize()
void setMaxTextMessageBufferSize(int length)
length
- the maximum length.int getMaxTextMessageBufferSize()
RemoteEndpoint getRemote()
String getId()
void close() throws IOException
close
in interface Closeable
IOException
- if there was a connection error closing the connection.void close(CloseReason closeReason) throws IOException
CloseReason.CloseCodes.NO_STATUS_CODE
.
closeReason
- the reason for the closure.
IOException
- if there was a connection error closing the connectionURI getRequestURI()
Map<String,List<String>> getRequestParameterMap()
String getQueryString()
Map<String,String> getPathParameters()
Map<String,Object> getUserProperties()
Principal getUserPrincipal()
Set<Session> getOpenSessions()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |