org.glassfish.tyrus.platform
Class SessionImpl

java.lang.Object
  extended by org.glassfish.tyrus.platform.SessionImpl
All Implemented Interfaces:
Session

public class SessionImpl
extends Object
implements Session

Implementation of the WebSocketConversation.

Author:
Danny Coward, Stepan Kopriva (stepan.kopriva at oracle.com)

Method Summary
 void addEncoder(Encoder encoder)
           
 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 closeReason)
          Closes the underlying connection this session is based upon.
 CloseReason getCloseStatus()
          If this session is no longer active, returns the reason for closure.
 Long getId()
          Return a unique ID for this session.
 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()
          Web Socket protocol version 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 maximumMessageSize)
          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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getProtocolVersion

public String getProtocolVersion()
Web Socket protocol version used.

Specified by:
getProtocolVersion in interface Session
Returns:
protocol version

getSession

public javax.servlet.http.HttpSession getSession()
Description copied from interface: Session
Return a reference to the HttpSession that the web socket handshake that started this conversation was part of, if applicable.

Specified by:
getSession in interface Session
Returns:

getNegotiatedSubprotocol

public String getNegotiatedSubprotocol()
Description copied from interface: Session
Return the sub protocol agreed during the websocket handshake for this conversation.

Specified by:
getNegotiatedSubprotocol in interface Session

getRemote

public RemoteEndpoint getRemote()
Description copied from interface: Session
Return a reference to the RemoteEndpoint object representing the other end of this conversation.

Specified by:
getRemote in interface Session

getRemote

public RemoteEndpoint getRemote(Class c)
Description copied from interface: Session
Return a reference to the RemoteEndpoint that can send messages in the form of objects of class c.

Specified by:
getRemote in interface Session

getId

public Long getId()
Return a unique ID for this session.

Returns:
id

isActive

public boolean isActive()
Description copied from interface: Session
Return true if and only if the underlying socket is open.

Specified by:
isActive in interface Session

getTimeout

public long getTimeout()
Description copied from interface: Session
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.

Specified by:
getTimeout in interface Session

close

public void close()
           throws IOException
Description copied from interface: Session
Close the current conversation with a normal status code and no reason phrase.

Specified by:
close in interface Session
Throws:
IOException

close

public void close(CloseReason closeReason)
           throws IOException
Closes the underlying connection this session is based upon.

Specified by:
close in interface Session
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

getCloseStatus

public CloseReason getCloseStatus()
Description copied from interface: Session
If this session is no longer active, returns the reason for closure. Otherwise, if the session is active, return null.

Specified by:
getCloseStatus in interface Session

setTimeout

public void setTimeout(long seconds)
Description copied from interface: Session
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.

Specified by:
setTimeout in interface Session

setMaximumMessageSize

public void setMaximumMessageSize(long maximumMessageSize)
Description copied from interface: Session
Sets the maximum total length of messages, text or binary, that this Session can handle.

Specified by:
setMaximumMessageSize in interface Session

getMaximumMessageSize

public long getMaximumMessageSize()
Description copied from interface: Session
The maximum total length of messages, text or binary, that this Session can handle.

Specified by:
getMaximumMessageSize in interface Session

getNegotiatedExtensions

public List<Extension> getNegotiatedExtensions()
Description copied from interface: Session
Return the list of extensions currently in use for this conversation.

Specified by:
getNegotiatedExtensions in interface Session

isSecure

public boolean isSecure()
Description copied from interface: Session
Return true if and only if the underlying socket is using a secure transport.

Specified by:
isSecure in interface Session

getInactiveTime

public long getInactiveTime()
Description copied from interface: Session
Return the number of seconds since the underlying connection had any activity.

Specified by:
getInactiveTime in interface Session

addEncoder

public void addEncoder(Encoder encoder)
Specified by:
addEncoder in interface Session

addMessageHandler

public void addMessageHandler(MessageHandler listener)
Description copied from interface: Session
Register to handle to incoming messages in this conversation.

Specified by:
addMessageHandler in interface Session

getMessageHandlers

public Set getMessageHandlers()
Description copied from interface: Session
Return an unmodifiable copy of the set of MessageHandlers for this Session.

Specified by:
getMessageHandlers in interface Session

removeMessageHandler

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

Specified by:
removeMessageHandler in interface Session

getRequestURI

public URI getRequestURI()
Description copied from interface: Session
Return the URI that this session was opened under.

Specified by:
getRequestURI in interface Session


Copyright © 2012. All Rights Reserved.