Interface ServerChannel
-
- All Superinterfaces:
Channel,ConfigurableServerChannel
- All Known Implementing Classes:
ServerChannelImpl
public interface ServerChannel extends ConfigurableServerChannel
Server side representation of a Bayeux channel.
ServerChannelis the entity that holds a set ofServerSessions that are subscribed to the channel itself.A message published to a
ServerChannelwill be delivered to all theServerSession's subscribed to the channel.Contrary to their client side counterpart (
ClientSessionChannel) aServerChannelis not scoped with a session.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceServerChannel.MessageListenerListeners objects that implement this interface will be notified of message publish.static interfaceServerChannel.SubscriptionListenerListener objects that implement this interface will be notified of subscription events.-
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ConfigurableServerChannel
ConfigurableServerChannel.Initializer, ConfigurableServerChannel.ServerChannelListener
-
-
Field Summary
-
Fields inherited from interface org.cometd.bayeux.Channel
META, META_CONNECT, META_DISCONNECT, META_HANDSHAKE, META_SUBSCRIBE, META_UNSUBSCRIBE, SERVICE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Set<ServerSession>getSubscribers()voidpublish(Session from, java.lang.Object data, Promise<java.lang.Boolean> promise)Publishes the given information to this channel.voidpublish(Session from, ServerMessage.Mutable message, Promise<java.lang.Boolean> promise)Publishes the given message to this channel, delivering the message to all theServerSessions subscribed to this channel.voidremove()Removes this channel, and all the children channels.booleansubscribe(ServerSession session)Subscribes the given session to this channel.booleanunsubscribe(ServerSession session)Unsubscribes the given session from this channel.-
Methods inherited from interface org.cometd.bayeux.Channel
getAttribute, getAttributeNames, getChannelId, getId, isBroadcast, isDeepWild, isMeta, isService, isWild, removeAttribute, setAttribute
-
Methods inherited from interface org.cometd.bayeux.server.ConfigurableServerChannel
addAuthorizer, addListener, getAuthorizers, getLazyTimeout, getListeners, isBroadcastToPublisher, isLazy, isPersistent, removeAuthorizer, removeListener, setBroadcastToPublisher, setLazy, setLazyTimeout, setPersistent
-
-
-
-
Method Detail
-
getSubscribers
java.util.Set<ServerSession> getSubscribers()
- Returns:
- a snapshot of the set of subscribers of this channel
-
subscribe
boolean subscribe(ServerSession session)
Subscribes the given session to this channel.
Subscriptions are effective for
broadcast channelsand are successful no-operations forservice channels.The subscription may fail if the session is already subscribed to the channel or if the session is expired or if the channel is a meta channel.
- Parameters:
session- the session to subscribe- Returns:
- whether the subscription succeeded
- See Also:
unsubscribe(ServerSession)
-
unsubscribe
boolean unsubscribe(ServerSession session)
Unsubscribes the given session from this channel.
Unsubscriptions are effective for
broadcast channelsand are successful no-operations forservice channels.The unsubscription may fail if the session is already unsubscribed from the channel or if the session is expired or if the channel is a meta channel.
- Parameters:
session- the session to unsubscribe- Returns:
- whether the unsubscription succeeded
-
publish
void publish(Session from, ServerMessage.Mutable message, Promise<java.lang.Boolean> promise)
Publishes the given message to this channel, delivering the message to all the
ServerSessions subscribed to this channel.- Parameters:
from- the session from which the message originatesmessage- the message to publishpromise- the promise to notify whether the message has been published- See Also:
publish(Session, Object, Promise)
-
publish
void publish(Session from, java.lang.Object data, Promise<java.lang.Boolean> promise)
Publishes the given information to this channel.
- Parameters:
from- the session from which the message originatesdata- the data of the messagepromise- the promise to notify whether the message has been published- See Also:
publish(Session, ServerMessage.Mutable, Promise)
-
remove
void remove()
Removes this channel, and all the children channels.
If channel "/foo", "/foo/bar" and "/foo/blip" exist, removing channel "/foo" will remove also "/foo/bar" and "/foo/blip".
The removal will notify
BayeuxServer.ChannelListenerlisteners.
-
-