org.cometd.server
Class ServerSessionImpl

java.lang.Object
  extended by org.cometd.server.ServerSessionImpl
All Implemented Interfaces:
ServerSession, Session

public class ServerSessionImpl
extends Object
implements ServerSession


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ServerSession
ServerSession.DeQueueListener, ServerSession.Extension, ServerSession.MaxQueueListener, ServerSession.MessageListener, ServerSession.RemoveListener, ServerSession.ServerSessionListener
 
Constructor Summary
protected ServerSessionImpl(BayeuxServerImpl bayeux)
           
protected ServerSessionImpl(BayeuxServerImpl bayeux, LocalSessionImpl localSession, String idHint)
           
 
Method Summary
 void addExtension(ServerSession.Extension extension)
           
 void addListener(ServerSession.ServerSessionListener listener)
           
 void addQueue(ServerMessage message)
           
 void batch(Runnable batch)
           
 long calculateInterval(long defaultInterval)
           
 long calculateTimeout(long defaultTimeout)
           
 void cancelIntervalTimeout()
           
 void cancelSchedule()
           
protected  void connect()
           
 void deliver(Session from, ServerMessage message)
           
 void deliver(Session from, String channelId, Object data, String id)
           
 void disconnect()
           
protected  void doDeliver(ServerSession from, ServerMessage message)
           
protected  void dump(StringBuilder b, String indent)
           
 boolean endBatch()
           
protected  boolean extendRecv(ServerMessage.Mutable message)
           
protected  ServerMessage extendSend(ServerMessage message)
           
 void flush()
           
 void flushLazy()
           
 Object getAdvice()
           
 Object getAttribute(String name)
           
 Set<String> getAttributeNames()
           
protected  List<ServerSession.Extension> getExtensions()
           
 String getId()
           
 long getInterval()
           
 LocalSession getLocalSession()
           
 Object getLock()
           
 Queue<ServerMessage> getQueue()
           
 long getTimeout()
           
 String getUserAgent()
          Get the userAgent.
protected  void handshake()
           
 boolean isConnected()
           
 boolean isHandshook()
           
 boolean isLocalSession()
           
 boolean isMetaConnectDeliveryOnly()
           
 boolean isQueueEmpty()
           
 void reAdvise()
           
 Object removeAttribute(String name)
           
protected  boolean removed(boolean timedout)
           
 void removeExtension(ServerSession.Extension extension)
           
 void removeListener(ServerSession.ServerSessionListener listener)
           
 void replaceQueue(List<ServerMessage> queue)
           
 void setAttribute(String name, Object value)
           
 void setInterval(long intervalMS)
           
 void setMetaConnectDeliveryOnly(boolean meta)
           
 void setScheduler(AbstractServerTransport.Scheduler scheduler)
           
 void setTimeout(long timeoutMS)
           
 void setUserAgent(String userAgent)
          Set the userAgent.
 void startBatch()
           
 void startIntervalTimeout()
           
protected  void subscribedTo(ServerChannelImpl channel)
           
protected  void sweep(long now)
           
 Object takeAdvice()
           
 List<ServerMessage> takeQueue()
           
 String toDetailString()
           
 String toString()
           
protected  void unsubscribedTo(ServerChannelImpl channel)
           
 void updateTransientInterval(long interval)
          Updates the transient timeout with the given value.
 void updateTransientTimeout(long timeout)
          Updates the transient timeout with the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerSessionImpl

protected ServerSessionImpl(BayeuxServerImpl bayeux)

ServerSessionImpl

protected ServerSessionImpl(BayeuxServerImpl bayeux,
                            LocalSessionImpl localSession,
                            String idHint)
Method Detail

getUserAgent

public String getUserAgent()
Get the userAgent.

Specified by:
getUserAgent in interface ServerSession
Returns:
the userAgent

setUserAgent

public void setUserAgent(String userAgent)
Set the userAgent.

Parameters:
userAgent - the userAgent to set

sweep

protected void sweep(long now)

getExtensions

protected List<ServerSession.Extension> getExtensions()

addExtension

public void addExtension(ServerSession.Extension extension)
Specified by:
addExtension in interface ServerSession

removeExtension

public void removeExtension(ServerSession.Extension extension)
Specified by:
removeExtension in interface ServerSession

batch

public void batch(Runnable batch)
Specified by:
batch in interface Session

deliver

public void deliver(Session from,
                    ServerMessage message)
Specified by:
deliver in interface ServerSession

deliver

public void deliver(Session from,
                    String channelId,
                    Object data,
                    String id)
Specified by:
deliver in interface ServerSession

doDeliver

protected void doDeliver(ServerSession from,
                         ServerMessage message)

handshake

protected void handshake()

connect

protected void connect()

disconnect

public void disconnect()
Specified by:
disconnect in interface Session

endBatch

public boolean endBatch()
Specified by:
endBatch in interface Session

getLocalSession

public LocalSession getLocalSession()
Specified by:
getLocalSession in interface ServerSession

isLocalSession

public boolean isLocalSession()
Specified by:
isLocalSession in interface ServerSession

startBatch

public void startBatch()
Specified by:
startBatch in interface Session

addListener

public void addListener(ServerSession.ServerSessionListener listener)
Specified by:
addListener in interface ServerSession

getId

public String getId()
Specified by:
getId in interface Session

getLock

public Object getLock()

getQueue

public Queue<ServerMessage> getQueue()

isQueueEmpty

public boolean isQueueEmpty()

addQueue

public void addQueue(ServerMessage message)

replaceQueue

public void replaceQueue(List<ServerMessage> queue)

takeQueue

public List<ServerMessage> takeQueue()

removeListener

public void removeListener(ServerSession.ServerSessionListener listener)
Specified by:
removeListener in interface ServerSession

setScheduler

public void setScheduler(AbstractServerTransport.Scheduler scheduler)

flush

public void flush()

flushLazy

public void flushLazy()

cancelSchedule

public void cancelSchedule()

cancelIntervalTimeout

public void cancelIntervalTimeout()

startIntervalTimeout

public void startIntervalTimeout()

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface Session

getAttributeNames

public Set<String> getAttributeNames()
Specified by:
getAttributeNames in interface Session

removeAttribute

public Object removeAttribute(String name)
Specified by:
removeAttribute in interface Session

setAttribute

public void setAttribute(String name,
                         Object value)
Specified by:
setAttribute in interface Session

isConnected

public boolean isConnected()
Specified by:
isConnected in interface Session

isHandshook

public boolean isHandshook()
Specified by:
isHandshook in interface Session

extendRecv

protected boolean extendRecv(ServerMessage.Mutable message)

extendSend

protected ServerMessage extendSend(ServerMessage message)

getAdvice

public Object getAdvice()

reAdvise

public void reAdvise()

takeAdvice

public Object takeAdvice()

getTimeout

public long getTimeout()

getInterval

public long getInterval()

setTimeout

public void setTimeout(long timeoutMS)

setInterval

public void setInterval(long intervalMS)

removed

protected boolean removed(boolean timedout)
Parameters:
timedout -
Returns:
True if the session was connected.

setMetaConnectDeliveryOnly

public void setMetaConnectDeliveryOnly(boolean meta)

isMetaConnectDeliveryOnly

public boolean isMetaConnectDeliveryOnly()

subscribedTo

protected void subscribedTo(ServerChannelImpl channel)

unsubscribedTo

protected void unsubscribedTo(ServerChannelImpl channel)

dump

protected void dump(StringBuilder b,
                    String indent)

toDetailString

public String toDetailString()

toString

public String toString()
Overrides:
toString in class Object

calculateTimeout

public long calculateTimeout(long defaultTimeout)

calculateInterval

public long calculateInterval(long defaultInterval)

updateTransientTimeout

public void updateTransientTimeout(long timeout)
Updates the transient timeout with the given value. If the transient timeout was already set, then it will be reset, to avoid that badly behaving clients always send timeout = 0 which will result in a busy polling loop.

Parameters:
timeout - the value to update the timeout to if not already set
See Also:
updateTransientInterval(long)

updateTransientInterval

public void updateTransientInterval(long interval)
Updates the transient timeout with the given value.

Parameters:
interval - the value to update the interval to if not already set
See Also:
updateTransientTimeout(long)


Copyright © 2008-2010 Dojo Foundation. All Rights Reserved.