protected abstract class AbstractClientSession.AbstractSessionChannel extends Object implements ClientSessionChannel, org.eclipse.jetty.util.component.Dumpable
A channel scoped to a ClientSession
.
ClientSessionChannel.ClientSessionChannelListener, ClientSessionChannel.MessageListener
META, META_CONNECT, META_DISCONNECT, META_HANDSHAKE, META_SUBSCRIBE, META_UNSUBSCRIBE, SERVICE
Modifier | Constructor and Description |
---|---|
protected |
AbstractSessionChannel(ChannelId id) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ClientSessionChannel.ClientSessionChannelListener listener)
Adds a listener to this channel.
|
void |
dump(Appendable out,
String indent) |
String |
dumpSelf() |
Object |
getAttribute(String name)
Retrieves the value of named channel attribute.
|
Set<String> |
getAttributeNames() |
ChannelId |
getChannelId() |
String |
getId() |
List<ClientSessionChannel.ClientSessionChannelListener> |
getListeners() |
List<ClientSessionChannel.MessageListener> |
getSubscribers() |
boolean |
isBroadcast()
A broadcasting channel is a channel that is neither a
meta channel nor a service channel . |
boolean |
isDeepWild()
Tells whether a channel contains the deep wild characters '**', for example
/foo/** |
boolean |
isMeta()
Tells whether the channel is a meta channel, that is if its
id starts with "/meta/" . |
boolean |
isReleased() |
boolean |
isService()
Tells whether the channel is a service channel, that is if its
id starts with "/service/" . |
boolean |
isWild()
Tells whether a channel contains the wild character '*', for example
/foo/* or if it is Channel.isDeepWild() . |
protected void |
nonFirstSubscribe(Message.Mutable message,
ClientSessionChannel.MessageListener listener,
ClientSession.MessageListener callback) |
protected void |
nonLastUnSubscribe(Message.Mutable message,
ClientSessionChannel.MessageListener listener,
ClientSession.MessageListener callback) |
protected void |
notifyMessageListeners(Message message) |
protected void |
notifyOnMessage(ClientSessionChannel.MessageListener listener,
Message message) |
void |
publish(Message.Mutable message,
ClientSession.MessageListener callback)
Publishes the given
message onto this channel, notifying the
given callback of the publish result. |
void |
publish(Object data,
ClientSession.MessageListener callback)
Publishes the given
data onto this channel, notifying the given
callback of the publish result, whether successful or unsuccessful. |
boolean |
release()
Releases this channel from its
ClientSession . |
Object |
removeAttribute(String name)
Removes a named channel attribute.
|
void |
removeListener(ClientSessionChannel.ClientSessionChannelListener listener)
Removes the given
listener from this channel. |
protected void |
resetSubscriptions() |
protected void |
sendSubscribe(Message.Mutable message,
ClientSessionChannel.MessageListener listener,
ClientSession.MessageListener callback) |
protected void |
sendUnSubscribe(Message.Mutable message,
ClientSession.MessageListener callback)
Deprecated.
|
protected void |
sendUnSubscribe(Message.Mutable message,
ClientSessionChannel.MessageListener listener,
ClientSession.MessageListener callback) |
void |
setAttribute(String name,
Object value)
Sets a named channel attribute value.
|
boolean |
subscribe(Message.Mutable message,
ClientSessionChannel.MessageListener listener,
ClientSession.MessageListener callback)
Subscribes the given
listener to receive messages sent to this channel. |
protected void |
throwIfReleased() |
String |
toString() |
void |
unsubscribe()
Unsubscribes all subscribers registered on this channel.
|
boolean |
unsubscribe(Message.Mutable message,
ClientSessionChannel.MessageListener listener,
ClientSession.MessageListener callback)
Unsubscribes the given
listener from receiving messages sent to this channel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSession, publish, subscribe, subscribe, unsubscribe, unsubscribe
protected AbstractSessionChannel(ChannelId id)
public ChannelId getChannelId()
getChannelId
in interface Channel
ChannelId
public void addListener(ClientSessionChannel.ClientSessionChannelListener listener)
ClientSessionChannel
Adds 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
.
addListener
in interface ClientSessionChannel
listener
- the listener to addClientSessionChannel.removeListener(ClientSessionChannelListener)
public void removeListener(ClientSessionChannel.ClientSessionChannelListener listener)
ClientSessionChannel
Removes the given listener
from this channel.
Removing a listener never involves communication with the server,
differently from ClientSessionChannel.unsubscribe(MessageListener)
.
removeListener
in interface ClientSessionChannel
listener
- the listener to removeClientSessionChannel.addListener(ClientSessionChannelListener)
public List<ClientSessionChannel.ClientSessionChannelListener> getListeners()
getListeners
in interface ClientSessionChannel
ClientSessionChannel.addListener(ClientSessionChannelListener)
public void publish(Object data, ClientSession.MessageListener callback)
ClientSessionChannel
Publishes the given data
onto this channel, notifying the given
callback
of the publish result, whether successful or unsuccessful.
publish
in interface ClientSessionChannel
data
- the data to publishcallback
- the message callback to notify of the publish resultClientSessionChannel.publish(Object)
,
ClientSessionChannel.publish(Message.Mutable, ClientSession.MessageListener)
public void publish(Message.Mutable message, ClientSession.MessageListener callback)
ClientSessionChannel
Publishes the given message
onto this channel, notifying the
given callback
of the publish result.
publish
in interface ClientSessionChannel
message
- the message to publishcallback
- the message callback to notify of the publish resultClientSessionChannel.publish(Object, ClientSession.MessageListener)
public boolean subscribe(Message.Mutable message, ClientSessionChannel.MessageListener listener, ClientSession.MessageListener callback)
ClientSessionChannel
Subscribes the given listener
to 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.
subscribe
in interface ClientSessionChannel
message
- the subscription messagelistener
- the listener to register and invoke when a message arrives on this channelcallback
- the callback to notify of the subscribe resultClientSessionChannel.unsubscribe(MessageListener)
,
ClientSessionChannel.addListener(ClientSessionChannelListener)
protected void sendSubscribe(Message.Mutable message, ClientSessionChannel.MessageListener listener, ClientSession.MessageListener callback)
protected void nonFirstSubscribe(Message.Mutable message, ClientSessionChannel.MessageListener listener, ClientSession.MessageListener callback)
public boolean unsubscribe(Message.Mutable message, ClientSessionChannel.MessageListener listener, ClientSession.MessageListener callback)
ClientSessionChannel
Unsubscribes the given listener
from 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.
unsubscribe
in interface ClientSessionChannel
message
- the unsubscription messagelistener
- the listener to unsubscribecallback
- the callback to notify of the unsubscribe resultClientSessionChannel.subscribe(MessageListener)
,
ClientSessionChannel.unsubscribe()
protected void sendUnSubscribe(Message.Mutable message, ClientSessionChannel.MessageListener listener, ClientSession.MessageListener callback)
@Deprecated protected void sendUnSubscribe(Message.Mutable message, ClientSession.MessageListener callback)
protected void nonLastUnSubscribe(Message.Mutable message, ClientSessionChannel.MessageListener listener, ClientSession.MessageListener callback)
public void unsubscribe()
ClientSessionChannel
Unsubscribes all subscribers registered on this channel.
unsubscribe
in interface ClientSessionChannel
ClientSessionChannel.subscribe(MessageListener)
public List<ClientSessionChannel.MessageListener> getSubscribers()
getSubscribers
in interface ClientSessionChannel
ClientSessionChannel.subscribe(MessageListener)
public boolean release()
ClientSessionChannel
Releases this channel from its ClientSession
.
If the release is successful, subsequent invocations of ClientSession.getChannel(String)
will return a new, different, instance of a ClientSessionChannel.
The release of a ClientSessionChannel is successful only if no listeners and no subscribers are present at the moment of the release.
release
in interface ClientSessionChannel
ClientSessionChannel.isReleased()
public boolean isReleased()
isReleased
in interface ClientSessionChannel
ClientSessionChannel.release()
protected void resetSubscriptions()
public String getId()
public boolean isDeepWild()
Channel
Tells whether a channel contains the deep wild characters '**', for example
/foo/**
isDeepWild
in interface Channel
public boolean isMeta()
Channel
Tells whether the channel is a meta channel, that is if its
id
starts with "/meta/"
.
public boolean isService()
Channel
Tells whether the channel is a service channel, that is if its
id
starts with "/service/"
.
public boolean isBroadcast()
Channel
A broadcasting channel is a channel that is neither a
meta channel
nor a service channel
.
isBroadcast
in interface Channel
public boolean isWild()
Channel
Tells whether a channel contains the wild character '*', for example
/foo/*
or if it is Channel.isDeepWild()
.
protected void notifyMessageListeners(Message message)
protected void notifyOnMessage(ClientSessionChannel.MessageListener listener, Message message)
public void setAttribute(String name, Object value)
Channel
Sets a named channel attribute value.
Channel attributes are convenience data that allows arbitrary application data to be associated with a channel.
setAttribute
in interface Channel
name
- the attribute namevalue
- the attribute valuepublic Object getAttribute(String name)
Channel
Retrieves the value of named channel attribute.
getAttribute
in interface Channel
name
- the name of the attributepublic Set<String> getAttributeNames()
getAttributeNames
in interface Channel
public Object removeAttribute(String name)
Channel
Removes a named channel attribute.
removeAttribute
in interface Channel
name
- the name of the attributeprotected void throwIfReleased()
public String dumpSelf()
dumpSelf
in interface org.eclipse.jetty.util.component.Dumpable
public void dump(Appendable out, String indent) throws IOException
dump
in interface org.eclipse.jetty.util.component.Dumpable
IOException
Copyright © 2008–2024 The CometD Project. All rights reserved.