public class ServerChannelImpl extends Object implements ServerChannel, org.eclipse.jetty.util.component.Dumpable
ServerChannel.MessageListener, ServerChannel.SubscriptionListener
ConfigurableServerChannel.Initializer, ConfigurableServerChannel.ServerChannelListener
META, META_CONNECT, META_DISCONNECT, META_HANDSHAKE, META_SUBSCRIBE, META_UNSUBSCRIBE, SERVICE
Modifier | Constructor and Description |
---|---|
protected |
ServerChannelImpl(BayeuxServerImpl bayeux,
ChannelId id) |
Modifier and Type | Method and Description |
---|---|
void |
addAuthorizer(Authorizer authorizer)
Adds the given
Authorizer that grants or denies operations on this channel. |
void |
addListener(ConfigurableServerChannel.ServerChannelListener listener) |
protected List<Authorizer> |
authorizers() |
void |
dump(Appendable out,
String indent) |
Object |
getAttribute(String name)
Retrieves the value of named channel attribute.
|
Set<String> |
getAttributeNames() |
List<Authorizer> |
getAuthorizers() |
ChannelId |
getChannelId() |
String |
getId() |
long |
getLazyTimeout() |
List<ConfigurableServerChannel.ServerChannelListener> |
getListeners() |
Set<ServerSession> |
getSubscribers() |
boolean |
isBroadcast()
A broadcasting channel is a channel that is neither a
meta channel nor a service channel . |
boolean |
isBroadcastToPublisher() |
boolean |
isDeepWild()
Tells whether a channel contains the deep wild characters '**', for example
/foo/** |
boolean |
isLazy() |
boolean |
isMeta()
Tells whether the channel is a meta channel, that is if its
id starts with "/meta/" . |
boolean |
isPersistent() |
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 List<ConfigurableServerChannel.ServerChannelListener> |
listeners() |
void |
publish(Session from,
Object data,
Promise<Boolean> promise)
Publishes the given information to this channel.
|
void |
publish(Session from,
ServerMessage.Mutable mutable,
Promise<Boolean> promise)
Publishes the given message to this channel, delivering
the message to all the
ServerSession s subscribed to
this channel. |
void |
remove()
Removes this channel, and all the children channels.
|
Object |
removeAttribute(String name)
Removes a named channel attribute.
|
void |
removeAuthorizer(Authorizer authorizer)
Removes the given
Authorizer . |
void |
removeListener(ConfigurableServerChannel.ServerChannelListener listener) |
void |
setAttribute(String name,
Object value)
Sets a named channel attribute value.
|
void |
setBroadcastToPublisher(boolean broadcastToPublisher)
Sets whether a publisher that is also a subscriber to the channel
will receive the messages it publishes on that channel.
|
void |
setLazy(boolean lazy)
A lazy channel marks all messages published to it as lazy.
|
void |
setLazyTimeout(long lazyTimeout)
Sets the lazy timeout for this channel.
|
void |
setPersistent(boolean persistent)
A persistent channel is not removed when the last subscription is removed
|
boolean |
subscribe(ServerSession session)
Subscribes the given session to this channel.
|
protected boolean |
subscribe(ServerSessionImpl session,
ServerMessage message) |
Set<ServerSession> |
subscribers() |
protected boolean |
sweep() |
String |
toString() |
boolean |
unsubscribe(ServerSession session)
Unsubscribes the given session from this channel.
|
protected boolean |
unsubscribe(ServerSessionImpl session,
ServerMessage message) |
protected ServerChannelImpl(BayeuxServerImpl bayeux, ChannelId id)
public boolean subscribe(ServerSession session)
ServerChannel
Subscribes the given session to this channel.
Subscriptions are effective for broadcast channels
and are successful no-operations for service 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.
subscribe
in interface ServerChannel
session
- the session to subscribeServerChannel.unsubscribe(ServerSession)
protected boolean subscribe(ServerSessionImpl session, ServerMessage message)
public boolean unsubscribe(ServerSession session)
ServerChannel
Unsubscribes the given session from this channel.
Unsubscriptions are effective for broadcast channels
and are successful no-operations for service 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.
unsubscribe
in interface ServerChannel
session
- the session to unsubscribeprotected boolean unsubscribe(ServerSessionImpl session, ServerMessage message)
public Set<ServerSession> getSubscribers()
getSubscribers
in interface ServerChannel
public Set<ServerSession> subscribers()
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 isDeepWild()
Channel
Tells whether a channel contains the deep wild characters '**', for example
/foo/**
isDeepWild
in interface Channel
public boolean isLazy()
isLazy
in interface ConfigurableServerChannel
ConfigurableServerChannel.setLazy(boolean)
public boolean isPersistent()
isPersistent
in interface ConfigurableServerChannel
ConfigurableServerChannel.setPersistent(boolean)
public boolean isWild()
Channel
Tells whether a channel contains the wild character '*', for example
/foo/*
or if it is Channel.isDeepWild()
.
public void setLazy(boolean lazy)
ConfigurableServerChannel
setLazy
in interface ConfigurableServerChannel
lazy
- whether the channel is lazyConfigurableServerChannel.isLazy()
public long getLazyTimeout()
getLazyTimeout
in interface ConfigurableServerChannel
ConfigurableServerChannel.setLazyTimeout(long)
public void setLazyTimeout(long lazyTimeout)
ConfigurableServerChannel
setLazyTimeout
in interface ConfigurableServerChannel
lazyTimeout
- the lazy timeout for this channelConfigurableServerChannel.setLazy(boolean)
public void setPersistent(boolean persistent)
ConfigurableServerChannel
setPersistent
in interface ConfigurableServerChannel
persistent
- whether the channel is persistentConfigurableServerChannel.isPersistent()
public void addListener(ConfigurableServerChannel.ServerChannelListener listener)
addListener
in interface ConfigurableServerChannel
listener
- the listener to addConfigurableServerChannel.removeListener(ServerChannelListener)
public boolean isBroadcastToPublisher()
isBroadcastToPublisher
in interface ConfigurableServerChannel
public void setBroadcastToPublisher(boolean broadcastToPublisher)
ConfigurableServerChannel
setBroadcastToPublisher
in interface ConfigurableServerChannel
broadcastToPublisher
- whether the channel broadcasts messages back to the publisherpublic void removeListener(ConfigurableServerChannel.ServerChannelListener listener)
removeListener
in interface ConfigurableServerChannel
listener
- the listener to removeConfigurableServerChannel.addListener(ServerChannelListener)
public List<ConfigurableServerChannel.ServerChannelListener> getListeners()
getListeners
in interface ConfigurableServerChannel
ConfigurableServerChannel.addListener(ServerChannelListener)
protected List<ConfigurableServerChannel.ServerChannelListener> listeners()
public ChannelId getChannelId()
getChannelId
in interface Channel
ChannelId
public String getId()
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 void publish(Session from, ServerMessage.Mutable mutable, Promise<Boolean> promise)
ServerChannel
Publishes the given message to this channel, delivering
the message to all the ServerSession
s subscribed to
this channel.
publish
in interface ServerChannel
from
- the session from which the message originatesmutable
- the message to publishpromise
- the promise to notify whether the message has been publishedServerChannel.publish(Session, Object, Promise)
public void publish(Session from, Object data, Promise<Boolean> promise)
ServerChannel
Publishes the given information to this channel.
publish
in interface ServerChannel
from
- the session from which the message originatesdata
- the data of the messagepromise
- the promise to notify whether the message has been publishedServerChannel.publish(Session, ServerMessage.Mutable, Promise)
protected boolean sweep()
public void remove()
ServerChannel
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.ChannelListener
listeners.
remove
in interface ServerChannel
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 attributepublic void addAuthorizer(Authorizer authorizer)
ConfigurableServerChannel
Adds the given Authorizer
that grants or denies operations on this channel.
Operations must be granted by at least one Authorizer and must not be denied by any.
addAuthorizer
in interface ConfigurableServerChannel
authorizer
- the Authorizer to addConfigurableServerChannel.removeAuthorizer(Authorizer)
,
Authorizer
public void removeAuthorizer(Authorizer authorizer)
ConfigurableServerChannel
Removes the given Authorizer
.
removeAuthorizer
in interface ConfigurableServerChannel
authorizer
- the Authorizer to removeConfigurableServerChannel.addAuthorizer(Authorizer)
public List<Authorizer> getAuthorizers()
getAuthorizers
in interface ConfigurableServerChannel
protected List<Authorizer> authorizers()
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.