javax.net.websocket
Interface Session

All Known Implementing Classes:
SessionImpl

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 active websocket session. The endpoint can then register interest in incoming messages that are part of this newly created conversation 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.

Since:
DRAFT 001
Author:
dannycoward

Method Summary
 void addEncoder(Encoder tme)
           
 void addMessageHandler(MessageHandler listener)
          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 closeStatus)
          Close the current conversation, giving a reason for the closure.
 CloseReason getCloseStatus()
          If this session is no longer active, returns the reason for closure.
 long getInactiveTime()
          Return the number of seconds since the underlying connection had any activity.
 long getMaximumMessageSize()
          The maximum total length of messages, text or binary, that this Session can handle.
 Set 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.
 String getProtocolVersion()
          Returns the version of the websocket protocol currently being used.
 RemoteEndpoint getRemote()
          Return a reference to the RemoteEndpoint object representing the other end of this conversation.
 RemoteEndpoint getRemote(Class c)
          Return a reference to the RemoteEndpoint that can send messages in the form of objects of class c.
 URI getRequestURI()
          Return the URI that this session was opened under.
 javax.servlet.http.HttpSession getSession()
          Return a reference to the HttpSession that the web socket handshake that started this conversation was part of, if applicable.
 long getTimeout()
          Return the number of seconds before this conversation will be closed by the container if it is inactive, ie no messages are either sent or received in that time.
 boolean isActive()
          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 listener)
          Remove the given MessageHandler from the set belonging to this session.
 void setMaximumMessageSize(long length)
          Sets the maximum total length of messages, text or binary, that this Session can handle.
 void setTimeout(long seconds)
          Set the number of seconds before this conversation will be closed by the container if it is inactive, ie no messages are either sent or received.
 

Method Detail

addEncoder

void addEncoder(Encoder tme)

addMessageHandler

void addMessageHandler(MessageHandler listener)
Register to handle to incoming messages in this conversation.


getMessageHandlers

Set getMessageHandlers()
Return an unmodifiable copy of the set of MessageHandlers for this Session.


removeMessageHandler

void removeMessageHandler(MessageHandler listener)
Remove the given MessageHandler from the set belonging to this session. TBD Threading issues wrt handler invocations vs removal


getProtocolVersion

String getProtocolVersion()
Returns 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".


getNegotiatedSubprotocol

String getNegotiatedSubprotocol()
Return the sub protocol agreed during the websocket handshake for this conversation.


getNegotiatedExtensions

List<Extension> getNegotiatedExtensions()
Return the list of extensions currently in use for this conversation.


isSecure

boolean isSecure()
Return true if and only if the underlying socket is using a secure transport.


getInactiveTime

long getInactiveTime()
Return the number of seconds since the underlying connection had any activity.


isActive

boolean isActive()
Return true if and only if the underlying socket is open.


getTimeout

long getTimeout()
Return the number of seconds before this conversation will be closed by the container if it is inactive, ie no messages are either sent or received in that time.


setTimeout

void setTimeout(long seconds)
Set the number of seconds before this conversation will be closed by the container if it is inactive, ie no messages are either sent or received.


setMaximumMessageSize

void setMaximumMessageSize(long length)
Sets the maximum total length of messages, text or binary, that this Session can handle.


getMaximumMessageSize

long getMaximumMessageSize()
The maximum total length of messages, text or binary, that this Session can handle.


getRemote

RemoteEndpoint getRemote()
Return a reference to the RemoteEndpoint object representing the other end of this conversation.


getRemote

RemoteEndpoint getRemote(Class c)
Return a reference to the RemoteEndpoint that can send messages in the form of objects of class c.


getSession

javax.servlet.http.HttpSession getSession()
Return a reference to the HttpSession that the web socket handshake that started this conversation was part of, if applicable.

Returns:

close

void close()
           throws IOException
Close the current conversation with a normal status code and no reason phrase.

Throws:
IOException

close

void close(CloseReason closeStatus)
           throws IOException
Close the current conversation, giving a reason for the closure. Note the websocket spec defines the acceptable uses of status codes and reason phrases.

Throws:
IOException

getCloseStatus

CloseReason getCloseStatus()
If this session is no longer active, returns the reason for closure. Otherwise, if the session is active, return null.


getRequestURI

URI getRequestURI()
Return the URI that this session was opened under.



Copyright © 2012. All Rights Reserved.