org.cometd.bayeux.client
Interface ClientSession

All Superinterfaces:
Session
All Known Subinterfaces:
LocalSession

public interface ClientSession
extends Session

This interface represents the client side Bayeux session.

In addition to the common Bayeux session, this interface provides method to configure extension, access channels and to initiate the communication with a Bayeux server(s).

Version:
$Revision: 1483 $ $Date: 2009-03-04 14:56:47 +0100 (Wed, 04 Mar 2009) $

Nested Class Summary
static interface ClientSession.Extension
          Extension API for client session.
 
Method Summary
 void addExtension(ClientSession.Extension extension)
          Adds an extension to this session.
 ClientSessionChannel getChannel(String channelName)
          Returns a client side channel scoped by this session.
 void handshake()
          Equivalent to handshake(null).
 void handshake(Map<String,Object> template)
          Initiates the bayeux protocol handshake with the server(s).
 void removeExtension(ClientSession.Extension extension)
          Removes an extension from this session.
 
Methods inherited from interface org.cometd.bayeux.Session
batch, disconnect, endBatch, getAttribute, getAttributeNames, getId, isConnected, isHandshook, removeAttribute, setAttribute, startBatch
 

Method Detail

addExtension

void addExtension(ClientSession.Extension extension)
Adds an extension to this session.

Parameters:
extension - the extension to add
See Also:
removeExtension(Extension)

removeExtension

void removeExtension(ClientSession.Extension extension)
Removes an extension from this session.

Parameters:
extension - the extension to remove
See Also:
addExtension(Extension)

handshake

void handshake()

Equivalent to handshake(null).


handshake

void handshake(Map<String,Object> template)

Initiates the bayeux protocol handshake with the server(s).

The handshake initiated by this method is asynchronous and does not wait for the handshake response.

Parameters:
template - additional fields to add to the handshake message.

getChannel

ClientSessionChannel getChannel(String channelName)

Returns a client side channel scoped by this session.

The channel name may be for a specific channel (e.g. "/foo/bar") or for a wild channel (e.g. "/meta/**" or "/foo/*").

This method will always return a channel, even if the the channel has not been created on the server side. The server side channel is only involved once a publish or subscribe method is called on the channel returned by this method.

Typical usage examples are:

     clientSession.getChannel("/foo/bar").subscribe(mySubscriptionListener);
     clientSession.getChannel("/foo/bar").publish("Hello");
     clientSession.getChannel("/meta/*").addListener(myMetaChannelListener);
 

Parameters:
channelName - specific or wild channel name.
Returns:
a channel scoped by this session.


Copyright © 2008-2010 Dojo Foundation. All Rights Reserved.