org.cometd
Interface Channel


public interface Channel

A Bayeux channel.

A Channel represents a routing path for messages to Clients, and looks like a directory path:

 /some/channel
 
Clients may subscribe to a channel and will be delivered all messages published to the channel.

Channels may be lazy, which means that all messages published to that channel will be marked as lazy. Lazy messages are queued but do not wake up waiting clients.

Version:
$Revision: 686 $ $Date: 2009-07-03 11:07:24 +0200 (Fri, 03 Jul 2009) $

Method Summary
 void addDataFilter(DataFilter filter)
          Adds the given DataFilter to this channel.
 void addListener(ChannelListener listener)
          Adds a channel listener to this channel.
 java.util.Collection<DataFilter> getDataFilters()
          Returns a collection copy of the data filters for this channel.
 java.lang.String getId()
           
 int getSubscriberCount()
           
 java.util.Collection<Client> getSubscribers()
          Returns a collection that is a copy of clients subscribed to this channel.
 boolean isLazy()
           
 boolean isPersistent()
          Indicates whether the channel is persistent or not.
 void publish(Client fromClient, java.lang.Object data, java.lang.String msgId)
          Publishes a message.
 boolean remove()
           
 DataFilter removeDataFilter(DataFilter filter)
          Removes the given DataFilter from this channel.
 void removeListener(ChannelListener listener)
          Removes the channel listener from this channel.
 void setLazy(boolean lazy)
          Sets the lazyness of the channel
 void setPersistent(boolean persistent)
          Sets the persistency of this channel.
 void subscribe(Client subscriber)
          Subscribes the given Client to this channel.
 void unsubscribe(Client subscriber)
          Unsubscribes the given Client from this channel.
 

Method Detail

remove

boolean remove()
Returns:
true if the channel has been removed, false if it was not possible to remove the channel

getId

java.lang.String getId()
Returns:
the channel's name

publish

void publish(Client fromClient,
             java.lang.Object data,
             java.lang.String msgId)
Publishes a message.

Parameters:
fromClient - the client source of the message, or null
data - the message data
msgId - the message ID or null

isPersistent

boolean isPersistent()
Indicates whether the channel is persistent or not. Non persistent channels are removed when the last subscription is removed.

Returns:
true if the Channel will persist even when all subscriptions are gone.
See Also:
setPersistent(boolean)

setPersistent

void setPersistent(boolean persistent)
Sets the persistency of this channel.

Parameters:
persistent - true if the channel is persistent, false otherwise

subscribe

void subscribe(Client subscriber)
Subscribes the given Client to this channel.

Parameters:
subscriber - the client to subscribe
See Also:
unsubscribe(Client)

unsubscribe

void unsubscribe(Client subscriber)
Unsubscribes the given Client from this channel.

Parameters:
subscriber - the client to unsubscribe
See Also:
subscribe(Client)

getSubscribers

java.util.Collection<Client> getSubscribers()
Returns a collection that is a copy of clients subscribed to this channel.

Returns:
the clients subscribed to this channel

getSubscriberCount

int getSubscriberCount()
Returns:
the number of clients subscribed to this channel

addDataFilter

void addDataFilter(DataFilter filter)
Adds the given DataFilter to this channel.

Parameters:
filter - the data filter to add
See Also:
removeDataFilter(DataFilter)

removeDataFilter

DataFilter removeDataFilter(DataFilter filter)
Removes the given DataFilter from this channel.

Parameters:
filter - the data filter to remove
Returns:
the removed data filter
See Also:
addDataFilter(DataFilter)

getDataFilters

java.util.Collection<DataFilter> getDataFilters()
Returns a collection copy of the data filters for this channel.

Returns:
the data filters for this channel

addListener

void addListener(ChannelListener listener)
Adds a channel listener to this channel.

Parameters:
listener - the listener to add
See Also:
removeListener(ChannelListener)

removeListener

void removeListener(ChannelListener listener)
Removes the channel listener from this channel.

Parameters:
listener - the listener to remove
See Also:
addListener(ChannelListener)

isLazy

boolean isLazy()
Returns:
whether the channel is lazy.
See Also:
setLazy(boolean)

setLazy

void setLazy(boolean lazy)
Sets the lazyness of the channel

Parameters:
lazy - true if channel is lazy


Copyright © 2010 Dojo Foundation. All Rights Reserved.