Class AbstractClientSession.AbstractSessionChannel
- All Implemented Interfaces:
Channel,ClientSessionChannel,org.eclipse.jetty.util.component.Dumpable
- Direct Known Subclasses:
BayeuxClient.BayeuxClientChannel,LocalSessionImpl.LocalChannel
- Enclosing class:
- AbstractClientSession
protected abstract class AbstractClientSession.AbstractSessionChannel extends Object implements ClientSessionChannel, org.eclipse.jetty.util.component.Dumpable
A channel scoped to a ClientSession.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cometd.bayeux.client.ClientSessionChannel
ClientSessionChannel.ClientSessionChannelListener, ClientSessionChannel.MessageListener -
Field Summary
Fields inherited from interface org.cometd.bayeux.Channel
META, META_CONNECT, META_DISCONNECT, META_HANDSHAKE, META_SUBSCRIBE, META_UNSUBSCRIBE, SERVICE -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSessionChannel(ChannelId id) -
Method Summary
Modifier and Type Method Description voidaddListener(ClientSessionChannel.ClientSessionChannelListener listener)Adds a listener to this channel.Stringdump()voiddump(Appendable out, String indent)ObjectgetAttribute(String name)Retrieves the value of named channel attribute.Set<String>getAttributeNames()ChannelIdgetChannelId()StringgetId()List<ClientSessionChannel.ClientSessionChannelListener>getListeners()List<ClientSessionChannel.MessageListener>getSubscribers()booleanisBroadcast()A broadcasting channel is a channel that is neither ameta channelnor aservice channel.booleanisDeepWild()Tells whether a channel contains the deep wild characters '**', for example/foo/**booleanisMeta()Tells whether the channel is a meta channel, that is if itsidstarts with"/meta/".booleanisReleased()booleanisService()Tells whether the channel is a service channel, that is if itsidstarts with"/service/".booleanisWild()Tells whether a channel contains the wild character '*', for example/foo/*or if it isChannel.isDeepWild().protected voidnotifyMessageListeners(Message message)protected voidnotifyOnMessage(ClientSessionChannel.MessageListener listener, Message message)voidpublish(Object data)Publishes the givendataonto this channel.voidpublish(Object data, ClientSessionChannel.MessageListener callback)Publishes the givendataonto this channel, notifying the givencallbackof the publish result, whether successful or unsuccessful.voidpublish(Message.Mutable message, ClientSessionChannel.MessageListener callback)Publishes the givenmessageonto this channel, notifying the givencallbackof the publish result.booleanrelease()Releases this channel from itsClientSession.ObjectremoveAttribute(String name)Removes a named channel attribute.voidremoveListener(ClientSessionChannel.ClientSessionChannelListener listener)Removes the givenlistenerfrom this channel.protected voidresetSubscriptions()protected voidsendSubscribe(ClientSessionChannel.MessageListener listener, ClientSessionChannel.MessageListener callback)protected voidsendUnSubscribe(ClientSessionChannel.MessageListener callback)voidsetAttribute(String name, Object value)Sets a named channel attribute value.voidsubscribe(ClientSessionChannel.MessageListener listener)Equivalent tosubscribe(listener, null).voidsubscribe(ClientSessionChannel.MessageListener listener, ClientSessionChannel.MessageListener callback)Subscribes the givenlistenerto receive messages sent to this channel.protected voidthrowIfReleased()StringtoString()voidunsubscribe()Unsubscribes all subscribers registered on this channel.voidunsubscribe(ClientSessionChannel.MessageListener listener)Equivalent tounsubscribe(listener, null).voidunsubscribe(ClientSessionChannel.MessageListener listener, ClientSessionChannel.MessageListener callback)Unsubscribes the givenlistenerfrom receiving messages sent to this channel.
-
Constructor Details
-
Method Details
-
getChannelId
- Specified by:
getChannelIdin interfaceChannel- Returns:
- The channel ID as a
ChannelId
-
addListener
Description copied from interface:ClientSessionChannelAdds a listener to this channel.
If the listener is a
ClientSessionChannel.MessageListener, it will be invoked if a message arrives to this channel.Adding a listener never involves communication with the server, differently from
ClientSessionChannel.subscribe(MessageListener).Listeners are best suited to receive messages from
meta channels.- Specified by:
addListenerin interfaceClientSessionChannel- Parameters:
listener- the listener to add- See Also:
ClientSessionChannel.removeListener(ClientSessionChannelListener)
-
removeListener
Description copied from interface:ClientSessionChannelRemoves the given
listenerfrom this channel.Removing a listener never involves communication with the server, differently from
ClientSessionChannel.unsubscribe(MessageListener).- Specified by:
removeListenerin interfaceClientSessionChannel- Parameters:
listener- the listener to remove- See Also:
ClientSessionChannel.addListener(ClientSessionChannelListener)
-
getListeners
- Specified by:
getListenersin interfaceClientSessionChannel- Returns:
- an immutable snapshot of the listeners
- See Also:
ClientSessionChannel.addListener(ClientSessionChannelListener)
-
publish
Description copied from interface:ClientSessionChannelPublishes the given
dataonto this channel.The
datapublished must not be null and can be any object that can be natively converted to JSON (numbers, strings, arrays, lists, maps), or objects for which a JSON converter has been registered with the infrastructure responsible of the JSON conversion.- Specified by:
publishin interfaceClientSessionChannel- Parameters:
data- the data to publish- See Also:
ClientSessionChannel.publish(Object, MessageListener)
-
publish
Description copied from interface:ClientSessionChannelPublishes the given
dataonto this channel, notifying the givencallbackof the publish result, whether successful or unsuccessful.- Specified by:
publishin interfaceClientSessionChannel- Parameters:
data- the data to publishcallback- the message callback to notify of the publish result- See Also:
ClientSessionChannel.publish(Object),ClientSessionChannel.publish(Message.Mutable, MessageListener)
-
publish
Description copied from interface:ClientSessionChannelPublishes the given
messageonto this channel, notifying the givencallbackof the publish result.- Specified by:
publishin interfaceClientSessionChannel- Parameters:
message- the message to publishcallback- the message callback to notify of the publish result- See Also:
ClientSessionChannel.publish(Object, MessageListener)
-
subscribe
Description copied from interface:ClientSessionChannelEquivalent to
subscribe(listener, null).- Specified by:
subscribein interfaceClientSessionChannel- Parameters:
listener- the listener to register and invoke when a message arrives on this channel.
-
subscribe
public void subscribe(ClientSessionChannel.MessageListener listener, ClientSessionChannel.MessageListener callback)Description copied from interface:ClientSessionChannelSubscribes the given
listenerto receive messages sent to this channel.Subscription involves communication with the server only for the first listener subscribed to this channel. Listeners registered after the first will not cause a message being sent to the server.
The callback parameter will be invoked upon acknowledgment of the subscription by the server, and therefore only for the first subscription to this channel.
- Specified by:
subscribein interfaceClientSessionChannel- Parameters:
listener- the listener to register and invoke when a message arrives on this channel.callback- the listener to notify of the subscribe result.- See Also:
ClientSessionChannel.unsubscribe(MessageListener),ClientSessionChannel.addListener(ClientSessionChannelListener)
-
sendSubscribe
protected void sendSubscribe(ClientSessionChannel.MessageListener listener, ClientSessionChannel.MessageListener callback) -
unsubscribe
Description copied from interface:ClientSessionChannelEquivalent to
unsubscribe(listener, null).- Specified by:
unsubscribein interfaceClientSessionChannel- Parameters:
listener- the listener to unsubscribe
-
unsubscribe
public void unsubscribe(ClientSessionChannel.MessageListener listener, ClientSessionChannel.MessageListener callback)Description copied from interface:ClientSessionChannelUnsubscribes the given
listenerfrom receiving messages sent to this channel.Unsubscription involves communication with the server only for the last listener unsubscribed from this channel.
The callback parameter will be invoked upon acknowledgment of the unsubscription by the server, and therefore only for the last unsubscription from this channel.
- Specified by:
unsubscribein interfaceClientSessionChannel- Parameters:
listener- the listener to unsubscribecallback- the listener to notify of the unsubscribe result.- See Also:
ClientSessionChannel.subscribe(MessageListener),ClientSessionChannel.unsubscribe()
-
sendUnSubscribe
-
unsubscribe
public void unsubscribe()Description copied from interface:ClientSessionChannelUnsubscribes all subscribers registered on this channel.
- Specified by:
unsubscribein interfaceClientSessionChannel- See Also:
ClientSessionChannel.subscribe(MessageListener)
-
getSubscribers
- Specified by:
getSubscribersin interfaceClientSessionChannel- Returns:
- an immutable snapshot of the subscribers
- See Also:
ClientSessionChannel.subscribe(MessageListener)
-
release
public boolean release()Description copied from interface:ClientSessionChannelReleases this channel from its
ClientSession.If the release is successful, subsequent invocations of
ClientSession.getChannel(String)will return a new, different, instance of aClientSessionChannel.The release of a
ClientSessionChannelis successful only if no listeners and no subscribers are present at the moment of the release.- Specified by:
releasein interfaceClientSessionChannel- Returns:
- true if the release was successful, false otherwise
- See Also:
ClientSessionChannel.isReleased()
-
isReleased
public boolean isReleased()- Specified by:
isReleasedin interfaceClientSessionChannel- Returns:
- whether this channel has been released
- See Also:
ClientSessionChannel.release()
-
resetSubscriptions
protected void resetSubscriptions() -
getId
-
isDeepWild
public boolean isDeepWild()Description copied from interface:ChannelTells whether a channel contains the deep wild characters '**', for example
/foo/**- Specified by:
isDeepWildin interfaceChannel- Returns:
- true if the channel contains the '**' characters
-
isMeta
public boolean isMeta()Description copied from interface:ChannelTells whether the channel is a meta channel, that is if its
idstarts with"/meta/". -
isService
public boolean isService()Description copied from interface:ChannelTells whether the channel is a service channel, that is if its
idstarts with"/service/". -
isBroadcast
public boolean isBroadcast()Description copied from interface:ChannelA broadcasting channel is a channel that is neither a
meta channelnor aservice channel.- Specified by:
isBroadcastin interfaceChannel- Returns:
- whether the channel is a broadcasting channel
-
isWild
public boolean isWild()Description copied from interface:ChannelTells whether a channel contains the wild character '*', for example
/foo/*or if it isChannel.isDeepWild(). -
notifyMessageListeners
-
notifyOnMessage
-
setAttribute
Description copied from interface:ChannelSets a named channel attribute value.
Channel attributes are convenience data that allows arbitrary application data to be associated with a channel.
- Specified by:
setAttributein interfaceChannel- Parameters:
name- the attribute namevalue- the attribute value
-
getAttribute
Description copied from interface:ChannelRetrieves the value of named channel attribute.
- Specified by:
getAttributein interfaceChannel- Parameters:
name- the name of the attribute- Returns:
- the attribute value or null if the attribute is not present
-
getAttributeNames
- Specified by:
getAttributeNamesin interfaceChannel- Returns:
- the list of channel attribute names.
-
removeAttribute
Description copied from interface:ChannelRemoves a named channel attribute.
- Specified by:
removeAttributein interfaceChannel- Parameters:
name- the name of the attribute- Returns:
- the value of the attribute
-
throwIfReleased
protected void throwIfReleased() -
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-
toString
-