public abstract class AbstractClientSession extends Object implements ClientSession, org.eclipse.jetty.util.component.Dumpable
Partial implementation of ClientSession
.
It handles extensions and batching, and provides utility methods to be used by subclasses.
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractClientSession.AbstractSessionChannel
A channel scoped to a
ClientSession . |
ClientSession.Extension, ClientSession.MessageListener
Modifier | Constructor and Description |
---|---|
protected |
AbstractClientSession() |
Modifier and Type | Method and Description |
---|---|
void |
addExtension(ClientSession.Extension extension) |
void |
batch(Runnable batch) |
void |
dump(Appendable out,
String indent) |
boolean |
endBatch() |
protected void |
extendIncoming(org.cometd.bayeux.Message.Mutable message,
org.cometd.bayeux.Promise<Boolean> promise) |
protected void |
extendOutgoing(org.cometd.bayeux.Message.Mutable message,
org.cometd.bayeux.Promise<Boolean> promise) |
Object |
getAttribute(String name) |
Set<String> |
getAttributeNames() |
ClientSessionChannel |
getChannel(org.cometd.bayeux.ChannelId channelId) |
ClientSessionChannel |
getChannel(String channelName) |
protected ConcurrentMap<String,AbstractClientSession.AbstractSessionChannel> |
getChannels() |
List<ClientSession.Extension> |
getExtensions() |
protected boolean |
isBatching() |
protected abstract AbstractClientSession.AbstractSessionChannel |
newChannel(org.cometd.bayeux.ChannelId channelId) |
protected abstract org.cometd.bayeux.ChannelId |
newChannelId(String channelId) |
protected org.cometd.bayeux.Message.Mutable |
newMessage() |
protected String |
newMessageId() |
protected void |
notifyCallback(ClientSession.MessageListener callback,
org.cometd.bayeux.Message.Mutable message) |
protected void |
notifyListeners(org.cometd.bayeux.Message.Mutable message) |
void |
receive(org.cometd.bayeux.Message.Mutable message,
org.cometd.bayeux.Promise<Void> promise)
Receives a message (from the server) and process it.
|
protected void |
registerCallback(String messageId,
ClientSession.MessageListener callback) |
protected void |
registerSubscriber(String messageId,
ClientSessionChannel.MessageListener subscriber) |
void |
remoteCall(String target,
Object data,
ClientSession.MessageListener callback) |
Object |
removeAttribute(String name) |
void |
removeExtension(ClientSession.Extension extension) |
protected void |
resetSubscriptions() |
protected abstract void |
send(org.cometd.bayeux.Message.Mutable message) |
protected abstract void |
sendBatch() |
void |
setAttribute(String name,
Object value) |
void |
startBatch() |
protected ClientSession.MessageListener |
unregisterCallback(String messageId) |
protected ClientSessionChannel.MessageListener |
unregisterSubscriber(String messageId) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disconnect, disconnect, handshake, handshake, handshake
protected String newMessageId()
public void addExtension(ClientSession.Extension extension)
addExtension
in interface ClientSession
public void removeExtension(ClientSession.Extension extension)
removeExtension
in interface ClientSession
public List<ClientSession.Extension> getExtensions()
getExtensions
in interface ClientSession
protected void extendOutgoing(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Boolean> promise)
protected void extendIncoming(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Boolean> promise)
protected abstract org.cometd.bayeux.ChannelId newChannelId(String channelId)
protected abstract AbstractClientSession.AbstractSessionChannel newChannel(org.cometd.bayeux.ChannelId channelId)
public ClientSessionChannel getChannel(String channelName)
getChannel
in interface ClientSession
public ClientSessionChannel getChannel(org.cometd.bayeux.ChannelId channelId)
protected ConcurrentMap<String,AbstractClientSession.AbstractSessionChannel> getChannels()
public void startBatch()
startBatch
in interface org.cometd.bayeux.Session
protected abstract void sendBatch()
public boolean endBatch()
endBatch
in interface org.cometd.bayeux.Session
public void batch(Runnable batch)
batch
in interface org.cometd.bayeux.Session
protected boolean isBatching()
public Object getAttribute(String name)
getAttribute
in interface org.cometd.bayeux.Session
public Set<String> getAttributeNames()
getAttributeNames
in interface org.cometd.bayeux.Session
public Object removeAttribute(String name)
removeAttribute
in interface org.cometd.bayeux.Session
public void setAttribute(String name, Object value)
setAttribute
in interface org.cometd.bayeux.Session
public void remoteCall(String target, Object data, ClientSession.MessageListener callback)
remoteCall
in interface ClientSession
protected abstract void send(org.cometd.bayeux.Message.Mutable message)
protected org.cometd.bayeux.Message.Mutable newMessage()
protected void resetSubscriptions()
public void receive(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Void> promise)
Receives a message (from the server) and process it.
Processing the message involves calling the receive extensions
and the channel listeners
.
message
- the message received.promise
- the promise notified of the receive processingprotected void notifyListeners(org.cometd.bayeux.Message.Mutable message)
protected void notifyCallback(ClientSession.MessageListener callback, org.cometd.bayeux.Message.Mutable message)
protected void registerCallback(String messageId, ClientSession.MessageListener callback)
protected ClientSession.MessageListener unregisterCallback(String messageId)
protected void registerSubscriber(String messageId, ClientSessionChannel.MessageListener subscriber)
protected ClientSessionChannel.MessageListener unregisterSubscriber(String messageId)
public void dump(Appendable out, String indent) throws IOException
dump
in interface org.eclipse.jetty.util.component.Dumpable
IOException
Copyright © 2008–2023 The CometD Project. All rights reserved.