org.glassfish.tyrus
Class SessionImpl<T>

java.lang.Object
  extended by org.glassfish.tyrus.SessionImpl<T>
All Implemented Interfaces:
Session<T>

public class SessionImpl<T>
extends Object
implements Session<T>

Implementation of the WebSocketConversation.

Author:
Danny Coward (danny.coward at oracle.com), Stepan Kopriva (stepan.kopriva at oracle.com), Martin Matula (martin.matula at oracle.com)

Method Summary
 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.
 ClientContainer getContainer()
          Return the container that this session is part of.
 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<MessageHandler> getMessageHandlers()
          Return an unmodifiable copy of the set of MessageHandlers for this Session.
 List<String> 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.
 Map<String,String[]> getParameterMap()
          Return the request parameters associated with the request this session was opened under.
 Map<String,String> getPathParameters()
           
 Map<String,Object> getProperties()
           
 String getProtocolVersion()
          Web Socket protocol version 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.
 RemoteEndpoint<T> getRemoteL(Class<T> aClass)
          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.
 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 setEncoders(List<Encoder> encoders)
          Sets the list of encoders to be used in this session in order of preference.
 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<T>
Returns:
protocol version

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<T>
Returns:
the negotiated subprotocol.

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<T>
Returns:
the remote endpoint.

getRemoteL

public RemoteEndpoint<T> getRemoteL(Class<T> aClass)
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:
getRemoteL in interface Session<T>
Parameters:
aClass - the class of the RemoteEndpoint.
Returns:
the remote endpoint instance.

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<T>
Returns:
whether the session is active.

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<T>
Returns:
the timeout in seconds.

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<T>
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<T>
Parameters:
closeReason - the reason for the closure.
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

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<T>
Parameters:
seconds - the number of seconds.

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<T>

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<T>
Returns:
the message size.

getNegotiatedExtensions

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

Specified by:
getNegotiatedExtensions in interface Session<T>
Returns:
the negotiated extensions.

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<T>
Returns:
whether its using a secure transport.

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<T>
Returns:
the inactive time.

getContainer

public ClientContainer getContainer()
Description copied from interface: Session
Return the container that this session is part of.

Specified by:
getContainer in interface Session<T>
Returns:
the container

setEncoders

public void setEncoders(List<Encoder> encoders)
Description copied from interface: Session
Sets the list of encoders to be used in this session in order of preference. The first element in the list that matches for a given type will be used rather than a later element in the list that matches for a given type.

Specified by:
setEncoders in interface Session<T>
Parameters:
encoders - the list of encoders.

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<T>

getMessageHandlers

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

Specified by:
getMessageHandlers in interface Session<T>
Returns:
the set of message handlers.

removeMessageHandler

public void removeMessageHandler(MessageHandler listener)
Description copied from interface: Session
Remove the given MessageHandler from the set belonging to this session.

Specified by:
removeMessageHandler in interface Session<T>
Parameters:
listener - the handler to be removed. TBD Threading issues wrt handler invocations vs removal

getRequestURI

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

Specified by:
getRequestURI in interface Session<T>
Returns:
the request URI.

getParameterMap

public Map<String,String[]> getParameterMap()
Description copied from interface: Session
Return the request parameters associated with the request this session was opened under.

Specified by:
getParameterMap in interface Session<T>
Returns:
the unmodifiable map of the request parameters.

getPathParameters

public Map<String,String> getPathParameters()

getQueryString

public String getQueryString()
Description copied from interface: Session
Return the query string associated with the request this session was opened under.

Specified by:
getQueryString in interface Session<T>
Returns:

getProperties

public Map<String,Object> getProperties()


Copyright © 2012. All Rights Reserved.