The CometD project implements the Comet technique using the Bayeux protocol to provide a scalable HTTP-based messaging system.
In general, messaging system are made of a client part and of a server part that communicate via a procotol. This is captured by a pattern called half object plus protocol.

A org.cometd.bayeux.client.ClientSession is the client-side half object that represent a communication session with a Bayeux server.
When client session half objects are created by a client, they are not initially associated with a correspondent org.cometd.bayeux.server.ServerSession half object.
Only when a client session handshakes with the server, its correspondent server session is created, and the link between the two half objects is created.
The concept of client session is straightforward for remote clients, but it exist on server-side as well.
The Bayeux server only knows about server session half objects, and the only way to create a server session half object is to create its correspondent client session first, and then make it handshake with the server.
For this reason, on server-side, there is the additional concept of a org.cometd.bayeux.server.LocalSession, which extends org.cometd.bayeux.client.ClientSession; it is a client session that happens to live on the server, and hence is local to the server.
For example, server-side services are associated with a local session. Upon creation of the server-side service, the local session handshakes and creates the correspondent server session half object, so that the Bayeux server can treat remote sessions and local session in the same way via org.cometd.bayeux.server.ServerSession.
In the CometD implementation, the two halves communicate by exchanging Bayeux messages.
The Java API offers - on client-side - the org.cometd.bayeux.Message interface to interact with the content of a message in a read-only way.
Where user code is allowed to modify the content of a message, the inner sub-interface org.cometd.bayeux.Message.Mutable is passed as parameter to callback methods (for example in client-side extensions).
On server-side, the sub-interface org.cometd.bayeux.server.ServerMessage allows read-only interaction with messages, and the inner sub-interface org.cometd.bayeux.server.ServerMessage.Mutable is passed as parameter to callback methods where user code is allowed to modify the message (for example server-side extensions).
Messages are sent to channels.
A channel is a named topic to which messages are sent to and to which subscribers register if they are interested in receiving messages sent to that channel.
Channel names resembles directory paths and can be wildcarded, for example: /chat/room/1, /stocks/**, /cinema/trailers/*.
Bayeux channels are divided in three categories:
/meta/ and are reserved to the Bayeux protocol)/services/ and are used from client to server communication)On server-side, the sub-interface org.cometd.bayeux.server.ServerChannel allows interaction with the channel (for example by publishing messages or adding listeners).
On client-side, channels are scoped to the client session that provides them via org.cometd.bayeux.client.ClientSessionChannel.