Interface ServerSession
-
- All Superinterfaces:
Session
- All Known Implementing Classes:
ServerSessionImpl
public interface ServerSession extends Session
Objects implementing this interface are the server-side representation of remote Bayeux clients.
ServerSessioncontains the queue of messages to be delivered to the client; messages are normally queued on aServerSessionby publishing them to a channel to which the session is subscribed (viaServerChannel.publish(Session, ServerMessage.Mutable, Promise).The
deliver(Session, ServerMessage.Mutable, Promise)anddeliver(Session, String, Object, Promise)methods may be used to directly queue messages to a session without publishing them to all subscribers of a channel.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceServerSession.AddedListenerListener objects that implement this interface will be notified of session addition.static interfaceServerSession.DeQueueListenerListeners objects that implement this interface will be notified when the session queue is being drained to actually deliver the messages.static interfaceServerSession.ExtensionExtension API forServerSession.static interfaceServerSession.HeartBeatListenerListeners objects that implement this interface will be notified when a/meta/connectmessage is suspended by the server, and when it is subsequently resumed.static interfaceServerSession.MessageListenerListeners objects that implement this interface will be notified of message sending.static interfaceServerSession.QueueListenerListener objects that implement this interface will be notified when a message is queued in the session queue.static interfaceServerSession.QueueMaxedListenerListeners objects that implement this interface will be notified when the session queue is full.static interfaceServerSession.RemovedListenerListeners objects that implement this interface will be notified of session removal.static interfaceServerSession.ServerSessionListenerCommon interface forServerSessionlisteners.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddExtension(ServerSession.Extension extension)Adds the given extension to this session.voidaddListener(ServerSession.ServerSessionListener listener)Adds the given listener to this session.voiddeliver(Session sender, java.lang.String channel, java.lang.Object data, Promise<java.lang.Boolean> promise)Delivers the given information to this session.voiddeliver(Session sender, ServerMessage.Mutable message, Promise<java.lang.Boolean> promise)Delivers the given message to this session.java.util.List<ServerSession.Extension>getExtensions()longgetInterval()LocalSessiongetLocalSession()longgetMaxInterval()ServerTransportgetServerTransport()java.util.Set<ServerChannel>getSubscriptions()longgetTimeout()java.lang.StringgetUserAgent()booleanisBroadcastToPublisher()booleanisLocalSession()booleanisMetaConnectDeliveryOnly()voidremoveExtension(ServerSession.Extension extension)Removes the given extension from this session.voidremoveListener(ServerSession.ServerSessionListener listener)Removes the given listener from this session.voidsetBroadcastToPublisher(boolean broadcastToPublisher)Sets whether this session sends messages back to itself.voidsetInterval(long interval)voidsetMaxInterval(long maxInterval)voidsetMetaConnectDeliveryOnly(boolean metaConnectDeliveryOnly)Sets whether delivery of messages only happen via the/meta/connectchannel.voidsetTimeout(long timeout)-
Methods inherited from interface org.cometd.bayeux.Session
batch, disconnect, endBatch, getAttribute, getAttributeNames, getId, isConnected, isHandshook, removeAttribute, setAttribute, startBatch
-
-
-
-
Method Detail
-
addExtension
void addExtension(ServerSession.Extension extension)
Adds the given extension to this session.
- Parameters:
extension- the extension to add- See Also:
removeExtension(Extension)
-
removeExtension
void removeExtension(ServerSession.Extension extension)
Removes the given extension from this session.
- Parameters:
extension- the extension to remove- See Also:
addExtension(Extension)
-
getExtensions
java.util.List<ServerSession.Extension> getExtensions()
- Returns:
- an immutable list of extensions present in this ServerSession instance
- See Also:
addExtension(Extension)
-
addListener
void addListener(ServerSession.ServerSessionListener listener)
Adds the given listener to this session.
- Parameters:
listener- the listener to add- See Also:
removeListener(ServerSessionListener)
-
removeListener
void removeListener(ServerSession.ServerSessionListener listener)
Removes the given listener from this session.
- Parameters:
listener- the listener to remove- See Also:
addListener(ServerSessionListener)
-
getServerTransport
ServerTransport getServerTransport()
- Returns:
- the ServerTransport associated with this session
-
isLocalSession
boolean isLocalSession()
- Returns:
- whether this is a session for a local client on server-side
-
getLocalSession
LocalSession getLocalSession()
- Returns:
- the
LocalSessionassociated with this session, or null if this is a session representing a remote client.
-
deliver
void deliver(Session sender, ServerMessage.Mutable message, Promise<java.lang.Boolean> promise)
Delivers the given message to this session.
This is different from
ServerChannel.publish(Session, ServerMessage.Mutable, Promise)as the message is delivered only to this session and not to all subscribers of the channel.The message should still have a channel id specified, so that the ClientSession may identify the listeners the message should be delivered to.
- Parameters:
sender- the session delivering the messagemessage- the message to deliverpromise- the promise to notify with the result of the deliver- See Also:
deliver(Session, String, Object, Promise)
-
deliver
void deliver(Session sender, java.lang.String channel, java.lang.Object data, Promise<java.lang.Boolean> promise)
Delivers the given information to this session.
- Parameters:
sender- the session delivering the messagechannel- the channel of the messagedata- the data of the messagepromise- the promise to notify with the result of the deliver- See Also:
deliver(Session, ServerMessage.Mutable, Promise)
-
getSubscriptions
java.util.Set<ServerChannel> getSubscriptions()
- Returns:
- the set of channels to which this session is subscribed to
-
getUserAgent
java.lang.String getUserAgent()
- Returns:
- The string indicating the client user agent, or null if not known
-
getInterval
long getInterval()
- Returns:
- the period of time, in milliseconds, that the client associated with this session will wait before issuing a connect message, or -1 if the default value is used
- See Also:
ServerTransport.getInterval(),setInterval(long)
-
setInterval
void setInterval(long interval)
- Parameters:
interval- the period of time, in milliseconds, that the client associated with this session will wait before issuing a connect message
-
getTimeout
long getTimeout()
- Returns:
- the period of time, in milliseconds, that the server will hold connect messages for this session or -1 if the default value is used
- See Also:
ServerTransport.getTimeout()
-
setTimeout
void setTimeout(long timeout)
- Parameters:
timeout- the period of time, in milliseconds, that the server will hold connect messages for this session
-
getMaxInterval
long getMaxInterval()
- Returns:
- the max period of time, in milliseconds, that the server waits before expiring the session when the client does not send messages to the server, or -1 if the default value is used
-
setMaxInterval
void setMaxInterval(long maxInterval)
- Parameters:
maxInterval- the max period of time, in milliseconds, that the server waits before expiring the session
-
isMetaConnectDeliveryOnly
boolean isMetaConnectDeliveryOnly()
- Returns:
- whether delivery of messages only happens via the
/meta/connectchannel
-
setMetaConnectDeliveryOnly
void setMetaConnectDeliveryOnly(boolean metaConnectDeliveryOnly)
Sets whether delivery of messages only happen via the
/meta/connectchannel.Transports that use more than one connection to the server (e.g. HTTP transports) may deliver some messages in one connection and some in another connection, causing messages to arrive out-of-order.
Forcing messages to be delivered only via the
/meta/connectchannel guarantees server-to-client message ordering.- Parameters:
metaConnectDeliveryOnly- whether delivery of messages only happens via the/meta/connectchannel
-
isBroadcastToPublisher
boolean isBroadcastToPublisher()
- Returns:
- whether this session sends messages back to itself
-
setBroadcastToPublisher
void setBroadcastToPublisher(boolean broadcastToPublisher)
Sets whether this session sends messages back to itself.- Parameters:
broadcastToPublisher- whether this session sends messages back to itself
-
-