org.apache.cometd.bayeux
Interface Channel

All Known Implementing Classes:
ChannelImpl

public interface Channel

A Bayeux Channel represents a channel used to receive messages from and to publish messages to. In order to publish messages to or receive messages from, one must subscribe to the channel. This is easily done by invoking the subscribe method. A channel is created by calling the Bayeux.getChannel(channelId,true) method. A channel can be created either server side by invoking the getChannel, or client side by using the /meta/subscribe message without a wildcard.

Author:
Greg Wilkins, Filip Hanik

Method Summary
 void addFilter(DataFilter filter)
          Adds a data filter to this channel.
 java.lang.String getId()
          Returns the id for this channel.
 java.util.List<Client> getSubscribers()
          returns a non modifiable list of all the subscribers to this channel.
 boolean isPersistent()
          Non persistent channels are removed when the last subscription is removed.
 void publish(Message msg)
          Publishes a message to all the subscribers of this channel.
 void publish(Message[] msgs)
          Publishes more than one message to all the subscribers of this channel.
 DataFilter removeFilter(DataFilter filter)
          Removes a filter from this channel.
 void setPersistent(boolean persistent)
           
 void subscribe(Client subscriber)
          Subscribes a client to a channel.
 Client unsubscribe(Client subscriber)
          Unsubscribes a client from a channel
 

Method Detail

getId

java.lang.String getId()
Returns the id for this channel. The id is unique within bayeux session.

Returns:
String - will never be null.

publish

void publish(Message msg)
Publishes a message to all the subscribers of this channel. The from is contained within the message, by calling msg.getClient()

Parameters:
data - - the message to be published, can not be null.

publish

void publish(Message[] msgs)
Publishes more than one message to all the subscribers of this channel. The from is contained within the message, by calling msg[x].getClient()

Parameters:
data - - the message to be published, can not be null.

isPersistent

boolean isPersistent()
Non persistent channels are removed when the last subscription is removed. Persistent channels survive periods without any subscribers.

Returns:
true if the Channel will persist without any subscription.

setPersistent

void setPersistent(boolean persistent)
Parameters:
persistent - true if the Channel will persist without any subscription.
See Also:
isPersistent

subscribe

void subscribe(Client subscriber)
Subscribes a client to a channel.

Parameters:
subscriber - - the client to be subscribed. If the client already is subscribed, this call will not create a duplicate subscription.

unsubscribe

Client unsubscribe(Client subscriber)
Unsubscribes a client from a channel

Parameters:
subscriber - - the client to be subscribed.
Returns:
- returns the client that was unsubscribed, or null if the client wasn't subscribed.

getSubscribers

java.util.List<Client> getSubscribers()
returns a non modifiable list of all the subscribers to this channel.

Returns:
a list of subscribers

addFilter

void addFilter(DataFilter filter)
Adds a data filter to this channel. All messages received by this channel will run through this filter.

Parameters:
filter - Filter

removeFilter

DataFilter removeFilter(DataFilter filter)
Removes a filter from this channel. returns the filter that was removed, or null if the filter wasn't in the channel.

Parameters:
filter - Filter
Returns:
Filter - null if no filter was removed otherwise it returns the filter that was removed.


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.