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
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY
-
Constructor Summary
Constructors Constructor Description ServerSessionImpl(BayeuxServerImpl bayeux)
ServerSessionImpl(BayeuxServerImpl bayeux, LocalSessionImpl localSession, java.lang.String idHint)
-
Method Summary
Modifier and Type Method Description void
addExtension(ServerSession.Extension extension)
void
addListener(ServerSession.ServerSessionListener listener)
protected void
addMessage(ServerMessage message)
void
batch(java.lang.Runnable batch)
long
calculateInterval(long defaultInterval)
long
calculateTimeout(long defaultTimeout)
void
cancelExpiration(boolean metaConnect)
protected boolean
connected()
void
deliver(org.cometd.bayeux.Session sender, java.lang.String channelId, java.lang.Object data, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
void
deliver(org.cometd.bayeux.Session sender, ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
protected void
deliver1(ServerSession sender, ServerMessage.Mutable mutable, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
void
destroyScheduler()
void
disconnect()
void
dump(java.lang.Appendable out, java.lang.String indent)
boolean
endBatch()
protected void
extendIncoming(ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
protected void
extendOutgoing(ServerSession sender, ServerMessage.Mutable message, org.cometd.bayeux.Promise<ServerMessage.Mutable> promise)
void
flush()
java.lang.Object
getAttribute(java.lang.String name)
java.util.Set<java.lang.String>
getAttributeNames()
BayeuxServerImpl
getBayeuxServer()
java.lang.String
getBrowserId()
java.util.List<ServerSession.Extension>
getExtensions()
java.lang.String
getId()
long
getInterval()
java.util.List<ServerSession.ServerSessionListener>
getListeners()
LocalSession
getLocalSession()
java.util.concurrent.locks.Lock
getLock()
long
getMaxInterval()
java.util.Queue<ServerMessage>
getQueue()
ServerTransport
getServerTransport()
java.util.Set<ServerChannel>
getSubscriptions()
long
getTimeout()
java.lang.String
getUserAgent()
protected boolean
handshake(ServerMessage.Mutable message)
boolean
hasNonLazyMessages()
boolean
isAllowMessageDeliveryDuringHandshake()
boolean
isBroadcastToPublisher()
boolean
isConnected()
boolean
isDisconnected()
boolean
isHandshook()
boolean
isLocalSession()
boolean
isMetaConnectDeliveryOnly()
boolean
isTerminated()
void
notifyResumed(ServerMessage message, boolean timeout)
void
notifySuspended(ServerMessage message, long timeout)
void
reAdvise()
java.lang.Object
removeAttribute(java.lang.String name)
protected boolean
removed(ServerMessage message, boolean timeout)
void
removeExtension(ServerSession.Extension extension)
void
removeListener(ServerSession.ServerSessionListener listener)
void
scheduleExpiration(long defaultInterval, long defaultMaxInterval, long metaConnectCycle)
void
setAllowMessageDeliveryDuringHandshake(boolean allow)
void
setAttribute(java.lang.String name, java.lang.Object value)
void
setBroadcastToPublisher(boolean value)
void
setBrowserId(java.lang.String browserId)
Sets a remote client identifier, typically a browser.void
setInterval(long intervalMS)
void
setMaxInterval(long maxInterval)
void
setMetaConnectDeliveryOnly(boolean meta)
void
setScheduler(AbstractServerTransport.Scheduler newScheduler)
void
setServerTransport(ServerTransport transport)
void
setTimeout(long timeoutMS)
void
setUserAgent(java.lang.String userAgent)
boolean
shouldSchedule()
void
startBatch()
protected boolean
subscribe(ServerChannelImpl channel)
protected void
sweep(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.String
toString()
protected void
unsubscribedFrom(ServerChannelImpl channel)
void
updateTransientInterval(long interval)
Updates the transient interval 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
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable
dump, dumpSelf
-
Constructor Details
-
ServerSessionImpl
-
ServerSessionImpl
public ServerSessionImpl(BayeuxServerImpl bayeux, LocalSessionImpl localSession, java.lang.String idHint)
-
-
Method Details
-
getBayeuxServer
-
getUserAgent
public java.lang.String getUserAgent()- Specified by:
getUserAgent
in 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 void sweep(long now) -
getSubscriptions
- Specified by:
getSubscriptions
in interfaceServerSession
-
addExtension
- Specified by:
addExtension
in interfaceServerSession
-
removeExtension
- Specified by:
removeExtension
in interfaceServerSession
-
getExtensions
- Specified by:
getExtensions
in interfaceServerSession
-
batch
public void batch(java.lang.Runnable batch)- Specified by:
batch
in 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:
deliver
in 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:
deliver
in 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
-
connected
protected boolean connected() -
disconnect
public void disconnect()- Specified by:
disconnect
in interfaceorg.cometd.bayeux.Session
-
startBatch
public void startBatch()- Specified by:
startBatch
in interfaceorg.cometd.bayeux.Session
-
endBatch
public boolean endBatch()- Specified by:
endBatch
in interfaceorg.cometd.bayeux.Session
-
getLocalSession
- Specified by:
getLocalSession
in interfaceServerSession
-
isLocalSession
public boolean isLocalSession()- Specified by:
isLocalSession
in interfaceServerSession
-
addListener
- Specified by:
addListener
in interfaceServerSession
-
getId
public java.lang.String getId()- Specified by:
getId
in interfaceorg.cometd.bayeux.Session
-
getLock
public java.util.concurrent.locks.Lock getLock() -
getQueue
-
hasNonLazyMessages
public boolean hasNonLazyMessages() -
addMessage
-
takeQueue
-
notifySuspended
-
notifyResumed
-
removeListener
- Specified by:
removeListener
in interfaceServerSession
-
getListeners
-
setScheduler
-
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:
getMaxInterval
in interfaceServerSession
-
setMaxInterval
public void setMaxInterval(long maxInterval)- Specified by:
setMaxInterval
in interfaceServerSession
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)- Specified by:
getAttribute
in interfaceorg.cometd.bayeux.Session
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()- Specified by:
getAttributeNames
in interfaceorg.cometd.bayeux.Session
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)- Specified by:
removeAttribute
in interfaceorg.cometd.bayeux.Session
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)- Specified by:
setAttribute
in interfaceorg.cometd.bayeux.Session
-
isHandshook
public boolean isHandshook()- Specified by:
isHandshook
in interfaceorg.cometd.bayeux.Session
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in 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
-
getServerTransport
- Specified by:
getServerTransport
in interfaceServerSession
-
setServerTransport
-
getTimeout
public long getTimeout()- Specified by:
getTimeout
in interfaceServerSession
-
getInterval
public long getInterval()- Specified by:
getInterval
in interfaceServerSession
-
setTimeout
public void setTimeout(long timeoutMS)- Specified by:
setTimeout
in interfaceServerSession
-
setInterval
public void setInterval(long intervalMS)- Specified by:
setInterval
in interfaceServerSession
-
isBroadcastToPublisher
public boolean isBroadcastToPublisher()- Specified by:
isBroadcastToPublisher
in interfaceServerSession
-
setBroadcastToPublisher
public void setBroadcastToPublisher(boolean value)- Specified by:
setBroadcastToPublisher
in interfaceServerSession
-
removed
- 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:
setMetaConnectDeliveryOnly
in interfaceServerSession
-
isMetaConnectDeliveryOnly
public boolean isMetaConnectDeliveryOnly()- Specified by:
isMetaConnectDeliveryOnly
in interfaceServerSession
-
isAllowMessageDeliveryDuringHandshake
public boolean isAllowMessageDeliveryDuringHandshake() -
setAllowMessageDeliveryDuringHandshake
public void setAllowMessageDeliveryDuringHandshake(boolean allow) -
subscribe
-
unsubscribedFrom
-
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:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-