public interface Session
A Bayeux session represents a connection between a bayeux client and a bayeux server.
This interface is the common base interface for both the server side and the client side representations of a session:
Modifier and Type | Method and Description |
---|---|
void |
batch(Runnable batch)
Executes the given command in a batch so that any Bayeux message sent
by the command (via the Bayeux API) is queued up until the end of the
command and then all messages are sent at once.
|
void |
disconnect()
Disconnects this session, ending the link between the client and the server peers.
|
boolean |
endBatch()
Ends a batch started with
startBatch() . |
Object |
getAttribute(String name)
Retrieves the value of named session attribute.
|
Set<String> |
getAttributeNames() |
String |
getId()
The clientId of the session.
|
boolean |
isConnected()
A connected session is a session where the link between the client and the server
has been established.
|
boolean |
isHandshook()
A handshook session is a session where the handshake has successfully completed
|
Object |
removeAttribute(String name)
Removes a named session attribute.
|
void |
setAttribute(String name,
Object value)
Sets a named session attribute value.
|
void |
startBatch()
Starts a batch, to be ended with
endBatch() . |
String getId()
The clientId of the session.
This would more correctly be called a "sessionId", but for backwards compatibility with the Bayeux protocol, it is a field called "clientId" that identifies a session.
boolean isConnected()
A connected session is a session where the link between the client and the server has been established.
disconnect()
boolean isHandshook()
A handshook session is a session where the handshake has successfully completed
void disconnect()
isConnected()
void setAttribute(String name, Object value)
Sets a named session attribute value.
Session attributes are convenience data that allows arbitrary application data to be associated with a session.
name
- the attribute namevalue
- the attribute valueObject getAttribute(String name)
Retrieves the value of named session attribute.
name
- the name of the attributeObject removeAttribute(String name)
Removes a named session attribute.
name
- the name of the attributevoid batch(Runnable batch)
Executes the given command in a batch so that any Bayeux message sent by the command (via the Bayeux API) is queued up until the end of the command and then all messages are sent at once.
batch
- the Runnable to run as a batchvoid startBatch()
Starts a batch, to be ended with endBatch()
.
The batch(Runnable)
method should be preferred since it automatically
starts and ends a batch without relying on a try/finally block.
This method is to be used in the cases where the use of batch(Runnable)
is not possible or would make the code more complex.
endBatch()
,
batch(Runnable)
boolean endBatch()
Ends a batch started with startBatch()
.
startBatch()
Copyright © 2008–2024 The CometD Project. All rights reserved.