Package org.cometd.server
Class ServerSessionImpl
- java.lang.Object
-
- org.cometd.server.ServerSessionImpl
-
- All Implemented Interfaces:
org.cometd.bayeux.server.ServerSession,org.cometd.bayeux.Session,org.eclipse.jetty.util.component.Dumpable
public class ServerSessionImpl extends java.lang.Object implements org.cometd.bayeux.server.ServerSession, org.eclipse.jetty.util.component.Dumpable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ServerSession
org.cometd.bayeux.server.ServerSession.DeQueueListener, org.cometd.bayeux.server.ServerSession.Extension, org.cometd.bayeux.server.ServerSession.MaxQueueListener, org.cometd.bayeux.server.ServerSession.MessageListener, org.cometd.bayeux.server.ServerSession.QueueListener, org.cometd.bayeux.server.ServerSession.RemoveListener, org.cometd.bayeux.server.ServerSession.ServerSessionListener
-
-
Constructor Summary
Constructors Constructor Description ServerSessionImpl(BayeuxServerImpl bayeux)ServerSessionImpl(BayeuxServerImpl bayeux, LocalSessionImpl localSession, java.lang.String idHint)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExtension(org.cometd.bayeux.server.ServerSession.Extension extension)voidaddListener(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)protected voidaddMessage(org.cometd.bayeux.server.ServerMessage message)voidbatch(java.lang.Runnable batch)longcalculateInterval(long defaultInterval)longcalculateTimeout(long defaultTimeout)voidcancelExpiration(boolean metaConnect)voidcancelSchedule()protected voidconnected()voiddeliver(org.cometd.bayeux.Session sender, java.lang.String channelId, java.lang.Object data)voiddeliver(org.cometd.bayeux.Session sender, org.cometd.bayeux.server.ServerMessage.Mutable message)voiddisconnect()protected voiddoDeliver(org.cometd.bayeux.server.ServerSession sender, org.cometd.bayeux.server.ServerMessage.Mutable mutable)java.lang.Stringdump()voiddump(java.lang.Appendable out, java.lang.String indent)booleanendBatch()protected booleanextendRecv(org.cometd.bayeux.server.ServerMessage.Mutable message)protected org.cometd.bayeux.server.ServerMessage.MutableextendSend(org.cometd.bayeux.server.ServerMessage.Mutable mutable)voidflush()java.lang.ObjectgetAttribute(java.lang.String name)java.util.Set<java.lang.String>getAttributeNames()BayeuxServerImplgetBayeuxServer()java.lang.StringgetBrowserId()java.util.List<org.cometd.bayeux.server.ServerSession.Extension>getExtensions()java.lang.StringgetId()longgetInterval()java.util.List<org.cometd.bayeux.server.ServerSession.ServerSessionListener>getListeners()org.cometd.bayeux.server.LocalSessiongetLocalSession()java.lang.ObjectgetLock()protected longgetMaxInterval()java.util.Queue<org.cometd.bayeux.server.ServerMessage>getQueue()java.util.Set<org.cometd.bayeux.server.ServerChannel>getSubscriptions()longgetTimeout()java.lang.StringgetUserAgent()protected voidhandshake()booleanhasNonLazyMessages()booleanisAllowMessageDeliveryDuringHandshake()booleanisBroadcastToPublisher()booleanisConnected()booleanisDisconnected()booleanisHandshook()booleanisLocalSession()booleanisMetaConnectDeliveryOnly()voidreAdvise()java.lang.ObjectremoveAttribute(java.lang.String name)protected booleanremoved(boolean timedOut)voidremoveExtension(org.cometd.bayeux.server.ServerSession.Extension extension)voidremoveListener(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)voidscheduleExpiration(long defaultInterval)voidsetAllowMessageDeliveryDuringHandshake(boolean allow)voidsetAttribute(java.lang.String name, java.lang.Object value)voidsetBroadcastToPublisher(boolean value)voidsetBrowserId(java.lang.String browserId)Sets a remote client identifier, typically a browser.voidsetInterval(long intervalMS)voidsetMetaConnectDeliveryOnly(boolean meta)voidsetScheduler(AbstractServerTransport.Scheduler newScheduler)voidsetTimeout(long timeoutMS)voidsetUserAgent(java.lang.String userAgent)booleanshouldSchedule()voidstartBatch()protected voidsubscribedTo(ServerChannelImpl channel)protected voidsweep(long now)java.util.Map<java.lang.String,java.lang.Object>takeAdvice(org.cometd.bayeux.server.ServerTransport transport)java.util.List<org.cometd.bayeux.server.ServerMessage>takeQueue()java.lang.StringtoString()protected voidunsubscribedFrom(ServerChannelImpl channel)voidupdateTransientInterval(long interval)Updates the transient interval with the given value.voidupdateTransientTimeout(long timeout)Updates the transient timeout with the given value.
-
-
-
Constructor Detail
-
ServerSessionImpl
public ServerSessionImpl(BayeuxServerImpl bayeux)
-
ServerSessionImpl
public ServerSessionImpl(BayeuxServerImpl bayeux, LocalSessionImpl localSession, java.lang.String idHint)
-
-
Method Detail
-
getBayeuxServer
public BayeuxServerImpl getBayeuxServer()
-
getUserAgent
public java.lang.String getUserAgent()
- Specified by:
getUserAgentin interfaceorg.cometd.bayeux.server.ServerSession- Returns:
- the remote user agent
-
setUserAgent
public void setUserAgent(java.lang.String userAgent)
- Parameters:
userAgent- the remote user agent
-
getBrowserId
public java.lang.String getBrowserId()
- Returns:
- the remote client identifier
-
setBrowserId
public void setBrowserId(java.lang.String browserId)
Sets a remote client identifier, typically a browser.
- Parameters:
browserId- the remote client identifier
-
sweep
protected void sweep(long now)
-
getSubscriptions
public java.util.Set<org.cometd.bayeux.server.ServerChannel> getSubscriptions()
- Specified by:
getSubscriptionsin interfaceorg.cometd.bayeux.server.ServerSession
-
addExtension
public void addExtension(org.cometd.bayeux.server.ServerSession.Extension extension)
- Specified by:
addExtensionin interfaceorg.cometd.bayeux.server.ServerSession
-
removeExtension
public void removeExtension(org.cometd.bayeux.server.ServerSession.Extension extension)
- Specified by:
removeExtensionin interfaceorg.cometd.bayeux.server.ServerSession
-
getExtensions
public java.util.List<org.cometd.bayeux.server.ServerSession.Extension> getExtensions()
- Specified by:
getExtensionsin interfaceorg.cometd.bayeux.server.ServerSession
-
batch
public void batch(java.lang.Runnable batch)
- Specified by:
batchin interfaceorg.cometd.bayeux.Session
-
deliver
public void deliver(org.cometd.bayeux.Session sender, org.cometd.bayeux.server.ServerMessage.Mutable message)- Specified by:
deliverin interfaceorg.cometd.bayeux.server.ServerSession
-
deliver
public void deliver(org.cometd.bayeux.Session sender, java.lang.String channelId, java.lang.Object data)- Specified by:
deliverin interfaceorg.cometd.bayeux.server.ServerSession
-
doDeliver
protected void doDeliver(org.cometd.bayeux.server.ServerSession sender, org.cometd.bayeux.server.ServerMessage.Mutable mutable)
-
extendSend
protected org.cometd.bayeux.server.ServerMessage.Mutable extendSend(org.cometd.bayeux.server.ServerMessage.Mutable mutable)
-
handshake
protected void handshake()
-
connected
protected void connected()
-
disconnect
public void disconnect()
- Specified by:
disconnectin interfaceorg.cometd.bayeux.Session
-
startBatch
public void startBatch()
- Specified by:
startBatchin interfaceorg.cometd.bayeux.Session
-
endBatch
public boolean endBatch()
- Specified by:
endBatchin interfaceorg.cometd.bayeux.Session
-
getLocalSession
public org.cometd.bayeux.server.LocalSession getLocalSession()
- Specified by:
getLocalSessionin interfaceorg.cometd.bayeux.server.ServerSession
-
isLocalSession
public boolean isLocalSession()
- Specified by:
isLocalSessionin interfaceorg.cometd.bayeux.server.ServerSession
-
addListener
public void addListener(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)
- Specified by:
addListenerin interfaceorg.cometd.bayeux.server.ServerSession
-
getId
public java.lang.String getId()
- Specified by:
getIdin interfaceorg.cometd.bayeux.Session
-
getLock
public java.lang.Object getLock()
-
getQueue
public java.util.Queue<org.cometd.bayeux.server.ServerMessage> getQueue()
-
hasNonLazyMessages
public boolean hasNonLazyMessages()
-
addMessage
protected void addMessage(org.cometd.bayeux.server.ServerMessage message)
-
takeQueue
public java.util.List<org.cometd.bayeux.server.ServerMessage> takeQueue()
-
removeListener
public void removeListener(org.cometd.bayeux.server.ServerSession.ServerSessionListener listener)
- Specified by:
removeListenerin interfaceorg.cometd.bayeux.server.ServerSession
-
getListeners
public java.util.List<org.cometd.bayeux.server.ServerSession.ServerSessionListener> getListeners()
-
setScheduler
public void setScheduler(AbstractServerTransport.Scheduler newScheduler)
-
shouldSchedule
public boolean shouldSchedule()
-
flush
public void flush()
-
cancelSchedule
public void cancelSchedule()
-
cancelExpiration
public void cancelExpiration(boolean metaConnect)
-
scheduleExpiration
public void scheduleExpiration(long defaultInterval)
-
getMaxInterval
protected long getMaxInterval()
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttributein interfaceorg.cometd.bayeux.Session
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceorg.cometd.bayeux.Session
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
- Specified by:
removeAttributein interfaceorg.cometd.bayeux.Session
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)- Specified by:
setAttributein interfaceorg.cometd.bayeux.Session
-
isHandshook
public boolean isHandshook()
- Specified by:
isHandshookin interfaceorg.cometd.bayeux.Session
-
isConnected
public boolean isConnected()
- Specified by:
isConnectedin interfaceorg.cometd.bayeux.Session
-
isDisconnected
public boolean isDisconnected()
-
extendRecv
protected boolean extendRecv(org.cometd.bayeux.server.ServerMessage.Mutable message)
-
reAdvise
public void reAdvise()
-
takeAdvice
public java.util.Map<java.lang.String,java.lang.Object> takeAdvice(org.cometd.bayeux.server.ServerTransport transport)
-
getTimeout
public long getTimeout()
- Specified by:
getTimeoutin interfaceorg.cometd.bayeux.server.ServerSession
-
getInterval
public long getInterval()
- Specified by:
getIntervalin interfaceorg.cometd.bayeux.server.ServerSession
-
setTimeout
public void setTimeout(long timeoutMS)
- Specified by:
setTimeoutin interfaceorg.cometd.bayeux.server.ServerSession
-
setInterval
public void setInterval(long intervalMS)
- Specified by:
setIntervalin interfaceorg.cometd.bayeux.server.ServerSession
-
isBroadcastToPublisher
public boolean isBroadcastToPublisher()
-
setBroadcastToPublisher
public void setBroadcastToPublisher(boolean value)
-
removed
protected boolean removed(boolean timedOut)
- Parameters:
timedOut- whether the session has been timed out- Returns:
- True if the session was connected.
-
setMetaConnectDeliveryOnly
public void setMetaConnectDeliveryOnly(boolean meta)
-
isMetaConnectDeliveryOnly
public boolean isMetaConnectDeliveryOnly()
-
isAllowMessageDeliveryDuringHandshake
public boolean isAllowMessageDeliveryDuringHandshake()
-
setAllowMessageDeliveryDuringHandshake
public void setAllowMessageDeliveryDuringHandshake(boolean allow)
-
subscribedTo
protected void subscribedTo(ServerChannelImpl channel)
-
unsubscribedFrom
protected void unsubscribedFrom(ServerChannelImpl channel)
-
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. The transient timeout is the one sent by the client, that should temporarily override the session/transport timeout, for example when the client sends {timeout:0}- Parameters:
timeout- the value to update the timeout to- See Also:
updateTransientInterval(long)
-
updateTransientInterval
public void updateTransientInterval(long interval)
Updates the transient interval with the given value. The transient interval is the one sent by the client, that should temporarily override the session/transport interval, for example when the client sends {timeout:0,interval:60000}- Parameters:
interval- the value to update the interval to- See Also:
updateTransientTimeout(long)
-
dump
public java.lang.String dump()
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-