Session
public interface ServerSession extends Session
Objects implementing this interface are the server-side representation of remote Bayeux clients.
ServerSession
contains the queue of messages to be delivered to the client; messages are
normally queued on a ServerSession
by publishing them to a channel to which the session is
subscribed (via ServerChannel.publish(Session, ServerMessage.Mutable, Promise)
.
The deliver(Session, ServerMessage.Mutable, Promise)
and deliver(Session, String, Object, Promise)
methods may be used to directly queue messages to a session without publishing them to all subscribers
of a channel.
Modifier and Type | Interface | Description |
---|---|---|
static interface |
ServerSession.DeQueueListener |
Listeners objects that implement this interface will be notified when the session queue
is being drained to actually deliver the messages.
|
static interface |
ServerSession.Extension |
Extension API for
ServerSession . |
static interface |
ServerSession.HeartBeatListener |
Listeners objects that implement this interface will be notified when a
/meta/connect
message is suspended by the server, and when it is subsequently resumed. |
static interface |
ServerSession.MaxQueueListener |
Listeners objects that implement this interface will be notified when the session queue is full.
|
static interface |
ServerSession.MessageListener |
Listeners objects that implement this interface will be notified of message sending.
|
static interface |
ServerSession.QueueListener |
Listener objects that implement this interface will be notified when a message
is queued in the session queue.
|
static interface |
ServerSession.RemoveListener |
Listeners objects that implement this interface will be notified of session removal.
|
static interface |
ServerSession.ServerSessionListener |
Common interface for
ServerSession listeners. |
Modifier and Type | Method | Description |
---|---|---|
void |
addExtension(ServerSession.Extension extension) |
Adds the given extension to this session.
|
void |
addListener(ServerSession.ServerSessionListener listener) |
Adds the given listener to this session.
|
default void |
deliver(Session sender,
String channel,
Object data) |
Deprecated.
use
deliver(Session, String, Object, Promise) instead |
void |
deliver(Session sender,
String channel,
Object data,
Promise<Boolean> promise) |
Delivers the given information to this session.
|
default void |
deliver(Session sender,
ServerMessage.Mutable message) |
Deprecated.
use
deliver(Session, ServerMessage.Mutable, Promise) instead |
void |
deliver(Session sender,
ServerMessage.Mutable message,
Promise<Boolean> promise) |
Delivers the given message to this session.
|
List<ServerSession.Extension> |
getExtensions() |
|
long |
getInterval() |
|
LocalSession |
getLocalSession() |
|
Set<ServerChannel> |
getSubscriptions() |
|
long |
getTimeout() |
|
String |
getUserAgent() |
|
boolean |
isLocalSession() |
|
void |
removeExtension(ServerSession.Extension extension) |
Removes the given extension from this session.
|
void |
removeListener(ServerSession.ServerSessionListener listener) |
Removes the given listener from this session.
|
void |
setInterval(long interval) |
|
void |
setTimeout(long timeout) |
batch, disconnect, endBatch, getAttribute, getAttributeNames, getId, isConnected, isHandshook, removeAttribute, setAttribute, startBatch
void addExtension(ServerSession.Extension extension)
Adds the given extension to this session.
extension
- the extension to addremoveExtension(Extension)
void removeExtension(ServerSession.Extension extension)
Removes the given extension from this session.
extension
- the extension to removeaddExtension(Extension)
List<ServerSession.Extension> getExtensions()
addExtension(Extension)
void addListener(ServerSession.ServerSessionListener listener)
Adds the given listener to this session.
listener
- the listener to addremoveListener(ServerSessionListener)
void removeListener(ServerSession.ServerSessionListener listener)
Removes the given listener from this session.
listener
- the listener to removeaddListener(ServerSessionListener)
boolean isLocalSession()
LocalSession getLocalSession()
LocalSession
associated with this session,
or null if this is a session representing a remote client.void deliver(Session sender, ServerMessage.Mutable message, Promise<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.
sender
- the session delivering the messagemessage
- the message to deliverpromise
- the promise to notify with the result of the deliverdeliver(Session, String, Object, Promise)
@Deprecated default void deliver(Session sender, ServerMessage.Mutable message)
deliver(Session, ServerMessage.Mutable, Promise)
insteadvoid deliver(Session sender, String channel, Object data, Promise<Boolean> promise)
Delivers the given information to this session.
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 deliverdeliver(Session, ServerMessage.Mutable, Promise)
@Deprecated default void deliver(Session sender, String channel, Object data)
deliver(Session, String, Object, Promise)
insteadSet<ServerChannel> getSubscriptions()
String getUserAgent()
long getInterval()
ServerTransport.getInterval()
,
setInterval(long)
void setInterval(long interval)
interval
- the period of time, in milliseconds, that the client
associated with this session will wait before issuing a connect messagelong getTimeout()
ServerTransport.getTimeout()
void setTimeout(long timeout)
timeout
- the period of time, in milliseconds, that the server will hold connect
messages for this sessionCopyright © 2008–2017 The CometD Project. All rights reserved.