Package org.cometd.server
Class ServerSessionImpl
- java.lang.Object
-
- org.cometd.server.ServerSessionImpl
-
- All Implemented Interfaces:
ServerSession,org.cometd.bayeux.Session,org.eclipse.jetty.util.component.Dumpable
public class ServerSessionImpl extends java.lang.Object implements ServerSession, org.eclipse.jetty.util.component.Dumpable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ServerSession
ServerSession.AddedListener, ServerSession.DeQueueListener, ServerSession.Extension, ServerSession.HeartBeatListener, ServerSession.MessageListener, ServerSession.QueueListener, ServerSession.QueueMaxedListener, ServerSession.RemovedListener, 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(ServerSession.Extension extension)voidaddListener(ServerSession.ServerSessionListener listener)protected voidaddMessage(ServerMessage message)voidbatch(java.lang.Runnable batch)longcalculateInterval(long defaultInterval)longcalculateTimeout(long defaultTimeout)voidcancelExpiration(boolean metaConnect)protected booleanconnected()voiddeliver(org.cometd.bayeux.Session sender, java.lang.String channelId, java.lang.Object data, org.cometd.bayeux.Promise<java.lang.Boolean> promise)voiddeliver(org.cometd.bayeux.Session sender, ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)protected voiddeliver1(ServerSession sender, ServerMessage.Mutable mutable, org.cometd.bayeux.Promise<java.lang.Boolean> promise)voiddestroyScheduler()voiddisconnect()voiddump(java.lang.Appendable out, java.lang.String indent)booleanendBatch()protected voidextendIncoming(ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)protected voidextendOutgoing(ServerSession sender, ServerMessage.Mutable message, org.cometd.bayeux.Promise<ServerMessage.Mutable> promise)voidflush()java.lang.ObjectgetAttribute(java.lang.String name)java.util.Set<java.lang.String>getAttributeNames()BayeuxServerImplgetBayeuxServer()java.lang.StringgetBrowserId()java.util.List<ServerSession.Extension>getExtensions()java.lang.StringgetId()longgetInterval()java.util.List<ServerSession.ServerSessionListener>getListeners()LocalSessiongetLocalSession()java.util.concurrent.locks.LockgetLock()longgetMaxInterval()java.util.Queue<ServerMessage>getQueue()ServerTransportgetServerTransport()java.util.Set<ServerChannel>getSubscriptions()longgetTimeout()java.lang.StringgetUserAgent()protected booleanhandshake(ServerMessage.Mutable message)booleanhasNonLazyMessages()booleanisAllowMessageDeliveryDuringHandshake()booleanisBroadcastToPublisher()booleanisConnected()booleanisDisconnected()booleanisHandshook()booleanisLocalSession()booleanisMetaConnectDeliveryOnly()booleanisTerminated()voidnotifyResumed(ServerMessage message, boolean timeout)voidnotifySuspended(ServerMessage message, long timeout)voidreAdvise()java.lang.ObjectremoveAttribute(java.lang.String name)protected booleanremoved(ServerMessage message, boolean timeout)voidremoveExtension(ServerSession.Extension extension)voidremoveListener(ServerSession.ServerSessionListener listener)voidscheduleExpiration(long defaultInterval, long defaultMaxInterval, long metaConnectCycle)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)voidsetMaxInterval(long maxInterval)voidsetMetaConnectDeliveryOnly(boolean meta)voidsetScheduler(AbstractServerTransport.Scheduler newScheduler)voidsetServerTransport(ServerTransport transport)voidsetTimeout(long timeoutMS)voidsetUserAgent(java.lang.String userAgent)booleanshouldSchedule()voidstartBatch()protected booleansubscribe(ServerChannelImpl channel)protected booleansweep(long now)java.util.Map<java.lang.String,java.lang.Object>takeAdvice(ServerTransport transport)java.util.List<ServerMessage>takeQueue(java.util.List<ServerMessage.Mutable> replies)java.lang.StringtoString()protected voidunsubscribedFrom(ServerChannelImpl channel)booleanupdateServerEndPoint(java.lang.Object newEndPoint)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 interfaceServerSession- 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 boolean sweep(long now)
-
getSubscriptions
public java.util.Set<ServerChannel> getSubscriptions()
- Specified by:
getSubscriptionsin interfaceServerSession
-
addExtension
public void addExtension(ServerSession.Extension extension)
- Specified by:
addExtensionin interfaceServerSession
-
removeExtension
public void removeExtension(ServerSession.Extension extension)
- Specified by:
removeExtensionin interfaceServerSession
-
getExtensions
public java.util.List<ServerSession.Extension> getExtensions()
- Specified by:
getExtensionsin interfaceServerSession
-
batch
public void batch(java.lang.Runnable batch)
- Specified by:
batchin interfaceorg.cometd.bayeux.Session
-
deliver
public void deliver(org.cometd.bayeux.Session sender, ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)- Specified by:
deliverin interfaceServerSession
-
deliver
public void deliver(org.cometd.bayeux.Session sender, java.lang.String channelId, java.lang.Object data, org.cometd.bayeux.Promise<java.lang.Boolean> promise)- Specified by:
deliverin interfaceServerSession
-
deliver1
protected void deliver1(ServerSession sender, ServerMessage.Mutable mutable, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
-
extendOutgoing
protected void extendOutgoing(ServerSession sender, ServerMessage.Mutable message, org.cometd.bayeux.Promise<ServerMessage.Mutable> promise)
-
handshake
protected boolean handshake(ServerMessage.Mutable message)
-
connected
protected boolean 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 LocalSession getLocalSession()
- Specified by:
getLocalSessionin interfaceServerSession
-
isLocalSession
public boolean isLocalSession()
- Specified by:
isLocalSessionin interfaceServerSession
-
addListener
public void addListener(ServerSession.ServerSessionListener listener)
- Specified by:
addListenerin interfaceServerSession
-
getId
public java.lang.String getId()
- Specified by:
getIdin interfaceorg.cometd.bayeux.Session
-
getLock
public java.util.concurrent.locks.Lock getLock()
-
getQueue
public java.util.Queue<ServerMessage> getQueue()
-
hasNonLazyMessages
public boolean hasNonLazyMessages()
-
addMessage
protected void addMessage(ServerMessage message)
-
takeQueue
public java.util.List<ServerMessage> takeQueue(java.util.List<ServerMessage.Mutable> replies)
-
notifySuspended
public void notifySuspended(ServerMessage message, long timeout)
-
notifyResumed
public void notifyResumed(ServerMessage message, boolean timeout)
-
removeListener
public void removeListener(ServerSession.ServerSessionListener listener)
- Specified by:
removeListenerin interfaceServerSession
-
getListeners
public java.util.List<ServerSession.ServerSessionListener> getListeners()
-
setScheduler
public void setScheduler(AbstractServerTransport.Scheduler newScheduler)
-
shouldSchedule
public boolean shouldSchedule()
-
flush
public void flush()
-
destroyScheduler
public void destroyScheduler()
-
cancelExpiration
public void cancelExpiration(boolean metaConnect)
-
scheduleExpiration
public void scheduleExpiration(long defaultInterval, long defaultMaxInterval, long metaConnectCycle)
-
getMaxInterval
public long getMaxInterval()
- Specified by:
getMaxIntervalin interfaceServerSession
-
setMaxInterval
public void setMaxInterval(long maxInterval)
- Specified by:
setMaxIntervalin interfaceServerSession
-
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()
-
isTerminated
public boolean isTerminated()
-
extendIncoming
protected void extendIncoming(ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
-
reAdvise
public void reAdvise()
-
takeAdvice
public java.util.Map<java.lang.String,java.lang.Object> takeAdvice(ServerTransport transport)
-
getServerTransport
public ServerTransport getServerTransport()
- Specified by:
getServerTransportin interfaceServerSession
-
setServerTransport
public void setServerTransport(ServerTransport transport)
-
updateServerEndPoint
public boolean updateServerEndPoint(java.lang.Object newEndPoint)
-
getTimeout
public long getTimeout()
- Specified by:
getTimeoutin interfaceServerSession
-
getInterval
public long getInterval()
- Specified by:
getIntervalin interfaceServerSession
-
setTimeout
public void setTimeout(long timeoutMS)
- Specified by:
setTimeoutin interfaceServerSession
-
setInterval
public void setInterval(long intervalMS)
- Specified by:
setIntervalin interfaceServerSession
-
isBroadcastToPublisher
public boolean isBroadcastToPublisher()
- Specified by:
isBroadcastToPublisherin interfaceServerSession
-
setBroadcastToPublisher
public void setBroadcastToPublisher(boolean value)
- Specified by:
setBroadcastToPublisherin interfaceServerSession
-
removed
protected boolean removed(ServerMessage message, boolean timeout)
- Parameters:
message- the message that caused the removal, or nulltimeout- whether the session has been removed due a timeout- Returns:
- True if the session was connected.
-
setMetaConnectDeliveryOnly
public void setMetaConnectDeliveryOnly(boolean meta)
- Specified by:
setMetaConnectDeliveryOnlyin interfaceServerSession
-
isMetaConnectDeliveryOnly
public boolean isMetaConnectDeliveryOnly()
- Specified by:
isMetaConnectDeliveryOnlyin interfaceServerSession
-
isAllowMessageDeliveryDuringHandshake
public boolean isAllowMessageDeliveryDuringHandshake()
-
setAllowMessageDeliveryDuringHandshake
public void setAllowMessageDeliveryDuringHandshake(boolean allow)
-
subscribe
protected boolean subscribe(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 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
-
-