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 String |
ADVICE_FIELD
Field names inside Bayeux messages - advice field
|
static String |
CHANNEL_FIELD
Field names inside Bayeux messages - channel field
|
static String |
CLIENT_FIELD
Field names inside Bayeux messages - clientId field
|
static String |
CONNECTION_TYPE_FIELD
Field names inside Bayeux messages - connectionType field
|
static String |
DATA_FIELD
Field names inside Bayeux messages - data field
|
static String |
DOJOX_COMETD_BAYEUX
ServletContext attribute name used to obtain the Bayeux object
|
static String |
ERROR_FIELD
Field names inside Bayeux messages - error field
|
static String |
EXT_FIELD
Field names inside Bayeux messages - ext field
|
static String |
HANDSHAKE_RESPONSE
Field values inside Bayeux messages - handshake response
|
static String |
ID_FIELD
Field names inside Bayeux messages - id field
|
static String |
INTERVAL_FIELD
Field names inside Bayeux messages - interval field
|
static String |
JSON_COMMENT_FILTERED_FIELD
Field names inside Bayeux messages - json-comment-filtered field
|
static String |
JSON_CONTENT_TYPE
http helpers - text/json content type
|
static String |
JSONP_DEFAULT_NAME
http helpers - default name of the jsonp callback function
|
static String |
JSONP_PARAMETER
http helpers - name of the jsonp parameter
|
static String |
MESSAGE_PARAMETER
http helpers - parameter name for json message
|
static String |
META
Meta definitions for channels
|
static String |
META_CLIENT
Meta definitions for channels - client messsage
|
static String |
META_CONNECT
Meta definitions for channels - connect message
|
static String |
META_DISCONNECT
Meta definitions for channels - disconnect messsage
|
static String |
META_HANDSHAKE
Meta definitions for channels - handshake messsage
|
static String |
META_PING
Meta definitions for channels - ping messsage
|
static String |
META_RECONNECT
Deprecated.
|
static String |
META_SLASH
Meta definitions for channels
|
static String |
META_STATUS
Meta definitions for channels - status messsage
|
static String |
META_SUBSCRIBE
Meta definitions for channels - subscribe messsage
|
static String |
META_UNSUBSCRIBE
Meta definitions for channels - unsubscribe messsage
|
static String |
MIN_VERSION_FIELD
Field names inside Bayeux messages - minimumVersion field
|
static String |
NONE_RESPONSE
Field values inside Bayeux messages - none response
|
static String |
RECONNECT_FIELD
Field names inside Bayeux messages - reconnect field
|
static String |
RETRY_RESPONSE
Field values inside Bayeux messages - retry response
|
static String |
SERVICE
Service channel names-starts with
|
static String |
SERVICE_SLASH
Service channel names-trailing slash
|
static String |
SUBSCRIPTION_FIELD
Field names inside Bayeux messages - subscription field
|
static String |
SUCCESSFUL_FIELD
Field names inside Bayeux messages - successful field
|
static String |
SUPP_CONNECTION_TYPE_FIELD
Field names inside Bayeux messages - supportedConnectionTypes field
|
static String |
TIMESTAMP_FIELD
Field names inside Bayeux messages - timestamp field
|
static String |
TRANSPORT_CALLBACK_POLL
Transport types - callback polling
|
static String |
TRANSPORT_FIELD
Field names inside Bayeux messages - transport field
|
static String |
TRANSPORT_FLASH
Transport types - flash
|
static String |
TRANSPORT_IFRAME
Transport types - iframe
|
static String |
TRANSPORT_LONG_POLL
Transport types - long polling
|
static String |
VERSION_FIELD
Field names inside Bayeux messages - version field
|
Modifier and Type | Method and Description |
---|---|
Channel |
getChannel(String channelId,
boolean create)
Returns the channel for a given channel id.
|
List<Channel> |
getChannels()
Returns a list of currently active channels in this Bayeux session.
|
Client |
getClient(String clientid)
retrieve a client based on an ID.
|
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(String channelId)
returns true if a channel with the given channelId exists.
|
boolean |
hasClient(String clientId)
Returns true if a client with the given id exists.
Same as executing getClient(id)!=null . |
Client |
newClient(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 String META
static final String META_SLASH
static final String META_CONNECT
static final String META_CLIENT
static final String META_DISCONNECT
static final String META_HANDSHAKE
static final String META_PING
static final String META_RECONNECT
static final String META_STATUS
static final String META_SUBSCRIBE
static final String META_UNSUBSCRIBE
static final String CLIENT_FIELD
static final String DATA_FIELD
static final String CHANNEL_FIELD
static final String ID_FIELD
static final String ERROR_FIELD
static final String TIMESTAMP_FIELD
static final String TRANSPORT_FIELD
static final String ADVICE_FIELD
static final String SUCCESSFUL_FIELD
static final String SUBSCRIPTION_FIELD
static final String EXT_FIELD
static final String CONNECTION_TYPE_FIELD
static final String VERSION_FIELD
static final String MIN_VERSION_FIELD
static final String SUPP_CONNECTION_TYPE_FIELD
static final String JSON_COMMENT_FILTERED_FIELD
static final String RECONNECT_FIELD
static final String INTERVAL_FIELD
static final String RETRY_RESPONSE
static final String HANDSHAKE_RESPONSE
static final String NONE_RESPONSE
static final String SERVICE
static final String SERVICE_SLASH
static final String TRANSPORT_LONG_POLL
static final String TRANSPORT_CALLBACK_POLL
static final String TRANSPORT_IFRAME
static final String TRANSPORT_FLASH
static final String DOJOX_COMETD_BAYEUX
static final String JSON_CONTENT_TYPE
static final String MESSAGE_PARAMETER
static final String JSONP_PARAMETER
static final String JSONP_DEFAULT_NAME
Client newClient(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(String clientid)
clientid
- StringList<Client> getClients()
boolean hasClient(String clientId)
getClient(id)!=null
.clientId
- StringClient remove(Client client)
client
- ClientChannel getChannel(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.List<Channel> getChannels()
Channel remove(Channel channel)
channel
- Channel - the channel to be removedboolean hasChannel(String channelId)
Bayeux.getChannel(channelId,false)!=null
channelId
- StringMessage newMessage(Client from)
SecurityPolicy getSecurityPolicy()
void setSecurityPolicy(SecurityPolicy securityPolicy)
securityPolicy
- SecurityPolicyCopyright © 2017 JBoss by Red Hat. All rights reserved.