public interface Bayeux
javax.servlet.ServletContext
object
as an attribute under the name Bayeux.DOJOX_COMETD_BAYEUX
Bayeux bx = (Bayeux)getServletContext().getAttribute(Bayeux.DOJOX_COMETD_BAYEUX);
The Bayeux protocol is pretty straight forward and includes a bunch of messaging that is not needed to be known to clients,
both server side and remote clients.
This object gets initialized by a container dependent servlet, and the servlet then handles all Bayeux communication from the client.
Remote messsages are delivered to channels, and to server side clients using the Listener
interface.
A Bayeux session
is active as long as the webapp hosting the Bayeux object is active.
When the webapplication shuts down, the Bayeux object will unsubscribe all clients and remove all the active channels.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ADVICE_FIELD
Field names inside Bayeux messages - advice field
|
static java.lang.String |
CHANNEL_FIELD
Field names inside Bayeux messages - channel field
|
static java.lang.String |
CLIENT_FIELD
Field names inside Bayeux messages - clientId field
|
static java.lang.String |
CONNECTION_TYPE_FIELD
Field names inside Bayeux messages - connectionType field
|
static java.lang.String |
DATA_FIELD
Field names inside Bayeux messages - data field
|
static java.lang.String |
DOJOX_COMETD_BAYEUX
ServletContext attribute name used to obtain the Bayeux object
|
static java.lang.String |
ERROR_FIELD
Field names inside Bayeux messages - error field
|
static java.lang.String |
EXT_FIELD
Field names inside Bayeux messages - ext field
|
static java.lang.String |
HANDSHAKE_RESPONSE
Field values inside Bayeux messages - handshake response
|
static java.lang.String |
ID_FIELD
Field names inside Bayeux messages - id field
|
static java.lang.String |
INTERVAL_FIELD
Field names inside Bayeux messages - interval field
|
static java.lang.String |
JSON_COMMENT_FILTERED_FIELD
Field names inside Bayeux messages - json-comment-filtered field
|
static java.lang.String |
JSON_CONTENT_TYPE
http helpers - text/json content type
|
static java.lang.String |
JSONP_DEFAULT_NAME
http helpers - default name of the jsonp callback function
|
static java.lang.String |
JSONP_PARAMETER
http helpers - name of the jsonp parameter
|
static java.lang.String |
MESSAGE_PARAMETER
http helpers - parameter name for json message
|
static java.lang.String |
META
Meta definitions for channels
|
static java.lang.String |
META_CLIENT
Meta definitions for channels - client messsage
|
static java.lang.String |
META_CONNECT
Meta definitions for channels - connect message
|
static java.lang.String |
META_DISCONNECT
Meta definitions for channels - disconnect messsage
|
static java.lang.String |
META_HANDSHAKE
Meta definitions for channels - handshake messsage
|
static java.lang.String |
META_PING
Meta definitions for channels - ping messsage
|
static java.lang.String |
META_RECONNECT
Deprecated.
|
static java.lang.String |
META_SLASH
Meta definitions for channels
|
static java.lang.String |
META_STATUS
Meta definitions for channels - status messsage
|
static java.lang.String |
META_SUBSCRIBE
Meta definitions for channels - subscribe messsage
|
static java.lang.String |
META_UNSUBSCRIBE
Meta definitions for channels - unsubscribe messsage
|
static java.lang.String |
MIN_VERSION_FIELD
Field names inside Bayeux messages - minimumVersion field
|
static java.lang.String |
NONE_RESPONSE
Field values inside Bayeux messages - none response
|
static java.lang.String |
RECONNECT_FIELD
Field names inside Bayeux messages - reconnect field
|
static java.lang.String |
RETRY_RESPONSE
Field values inside Bayeux messages - retry response
|
static java.lang.String |
SERVICE
Service channel names-starts with
|
static java.lang.String |
SERVICE_SLASH
Service channel names-trailing slash
|
static java.lang.String |
SUBSCRIPTION_FIELD
Field names inside Bayeux messages - subscription field
|
static java.lang.String |
SUCCESSFUL_FIELD
Field names inside Bayeux messages - successful field
|
static java.lang.String |
SUPP_CONNECTION_TYPE_FIELD
Field names inside Bayeux messages - supportedConnectionTypes field
|
static java.lang.String |
TIMESTAMP_FIELD
Field names inside Bayeux messages - timestamp field
|
static java.lang.String |
TRANSPORT_CALLBACK_POLL
Transport types - callback polling
|
static java.lang.String |
TRANSPORT_FIELD
Field names inside Bayeux messages - transport field
|
static java.lang.String |
TRANSPORT_FLASH
Transport types - flash
|
static java.lang.String |
TRANSPORT_IFRAME
Transport types - iframe
|
static java.lang.String |
TRANSPORT_LONG_POLL
Transport types - long polling
|
static java.lang.String |
VERSION_FIELD
Field names inside Bayeux messages - version field
|
Modifier and Type | Method and Description |
---|---|
Channel |
getChannel(java.lang.String channelId,
boolean create)
Returns the channel for a given channel id.
|
java.util.List<Channel> |
getChannels()
Returns a list of currently active channels in this Bayeux session.
|
Client |
getClient(java.lang.String clientid)
retrieve a client based on an ID.
|
java.util.List<Client> |
getClients()
Returns a non modifiable list of all the clients that are currently active
in this Bayeux session
|
SecurityPolicy |
getSecurityPolicy()
Returns the security policy associated with this Bayeux session
|
boolean |
hasChannel(java.lang.String channelId)
returns true if a channel with the given channelId exists.
|
boolean |
hasClient(java.lang.String clientId)
Returns true if a client with the given id exists.
Same as executing getClient(id)!=null . |
Client |
newClient(java.lang.String idprefix,
Listener listener)
Creates a new server side client.
|
Message |
newMessage(Client from)
Creates a new message to be sent by a server side client.
|
Channel |
remove(Channel channel)
Removes a channel from the Bayeux object.
|
Client |
remove(Client client)
Removes the client all together.
|
void |
setSecurityPolicy(SecurityPolicy securityPolicy)
Sets the security policy to be used in this Bayeux session
|
static final java.lang.String META
static final java.lang.String META_SLASH
static final java.lang.String META_CONNECT
static final java.lang.String META_CLIENT
static final java.lang.String META_DISCONNECT
static final java.lang.String META_HANDSHAKE
static final java.lang.String META_PING
static final java.lang.String META_RECONNECT
static final java.lang.String META_STATUS
static final java.lang.String META_SUBSCRIBE
static final java.lang.String META_UNSUBSCRIBE
static final java.lang.String CLIENT_FIELD
static final java.lang.String DATA_FIELD
static final java.lang.String CHANNEL_FIELD
static final java.lang.String ID_FIELD
static final java.lang.String ERROR_FIELD
static final java.lang.String TIMESTAMP_FIELD
static final java.lang.String TRANSPORT_FIELD
static final java.lang.String ADVICE_FIELD
static final java.lang.String SUCCESSFUL_FIELD
static final java.lang.String SUBSCRIPTION_FIELD
static final java.lang.String EXT_FIELD
static final java.lang.String CONNECTION_TYPE_FIELD
static final java.lang.String VERSION_FIELD
static final java.lang.String MIN_VERSION_FIELD
static final java.lang.String SUPP_CONNECTION_TYPE_FIELD
static final java.lang.String JSON_COMMENT_FILTERED_FIELD
static final java.lang.String RECONNECT_FIELD
static final java.lang.String INTERVAL_FIELD
static final java.lang.String RETRY_RESPONSE
static final java.lang.String HANDSHAKE_RESPONSE
static final java.lang.String NONE_RESPONSE
static final java.lang.String SERVICE
static final java.lang.String SERVICE_SLASH
static final java.lang.String TRANSPORT_LONG_POLL
static final java.lang.String TRANSPORT_CALLBACK_POLL
static final java.lang.String TRANSPORT_IFRAME
static final java.lang.String TRANSPORT_FLASH
static final java.lang.String DOJOX_COMETD_BAYEUX
static final java.lang.String JSON_CONTENT_TYPE
static final java.lang.String MESSAGE_PARAMETER
static final java.lang.String JSONP_PARAMETER
static final java.lang.String JSONP_DEFAULT_NAME
Client newClient(java.lang.String idprefix, Listener listener)
idprefix
- String - the prefix string for the id generated, can be nulllistener
- Listener - a callback object to be called when messages are to be delivered to the new clientClient getClient(java.lang.String clientid)
clientid
- Stringjava.util.List<Client> getClients()
boolean hasClient(java.lang.String clientId)
getClient(id)!=null
.clientId
- StringClient remove(Client client)
client
- ClientChannel getChannel(java.lang.String channelId, boolean create)
create
parameter is set to true,
the channel will be created and added to the list of active channels.create
is set to false, and the channel doesn't exist, null will be returned.channelId
- String - the id of the channel to be retrieved or createdcreate
- boolean - true if the Bayeux impl should create the channelcreate
is set to false and the channel doesn't exist,
otherwise it returns a channel object.java.util.List<Channel> getChannels()
Channel remove(Channel channel)
channel
- Channel - the channel to be removedboolean hasChannel(java.lang.String channelId)
Bayeux.getChannel(channelId,false)!=null
channelId
- StringMessage newMessage(Client from)
SecurityPolicy getSecurityPolicy()
void setSecurityPolicy(SecurityPolicy securityPolicy)
securityPolicy
- SecurityPolicy