Package org.cometd.common
Class AbstractClientSession
- java.lang.Object
-
- org.cometd.common.AbstractClientSession
-
- All Implemented Interfaces:
ClientSession,Session,org.eclipse.jetty.util.component.Dumpable
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractClientSession.AbstractSessionChannelA channel scoped to aClientSession.-
Nested classes/interfaces inherited from interface org.cometd.bayeux.client.ClientSession
ClientSession.Extension, ClientSession.MessageListener
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractClientSession()
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cometd.bayeux.client.ClientSession
disconnect, disconnect, disconnect, handshake, handshake, handshake, handshake
-
Methods inherited from interface org.cometd.bayeux.Session
getId, isConnected, isHandshook
-
-
-
-
Method Detail
-
newMessageId
protected String newMessageId()
-
addExtension
public void addExtension(ClientSession.Extension extension)
- Specified by:
addExtensionin interfaceClientSession
-
removeExtension
public void removeExtension(ClientSession.Extension extension)
- Specified by:
removeExtensionin interfaceClientSession
-
getExtensions
public List<ClientSession.Extension> getExtensions()
- Specified by:
getExtensionsin interfaceClientSession
-
extendOutgoing
protected void extendOutgoing(Message.Mutable message, Promise<Boolean> promise)
-
extendIncoming
protected void extendIncoming(Message.Mutable message, Promise<Boolean> promise)
-
newChannel
protected abstract AbstractClientSession.AbstractSessionChannel newChannel(ChannelId channelId)
-
getChannel
public ClientSessionChannel getChannel(String channelName)
- Specified by:
getChannelin interfaceClientSession
-
getChannel
public ClientSessionChannel getChannel(ChannelId channelId)
-
getChannels
protected ConcurrentMap<String,AbstractClientSession.AbstractSessionChannel> getChannels()
-
startBatch
public void startBatch()
- Specified by:
startBatchin interfaceSession
-
sendBatch
protected abstract void sendBatch()
-
isBatching
protected boolean isBatching()
-
getAttribute
public Object getAttribute(String name)
- Specified by:
getAttributein interfaceSession
-
getAttributeNames
public Set<String> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceSession
-
removeAttribute
public Object removeAttribute(String name)
- Specified by:
removeAttributein interfaceSession
-
setAttribute
public void setAttribute(String name, Object value)
- Specified by:
setAttributein interfaceSession
-
remoteCall
public void remoteCall(String target, Object data, ClientSession.MessageListener callback)
- Specified by:
remoteCallin interfaceClientSession
-
send
protected abstract void send(Message.Mutable message)
-
newMessage
protected Message.Mutable newMessage()
-
resetSubscriptions
protected void resetSubscriptions()
-
receive
public void receive(Message.Mutable message, Promise<Void> promise)
Receives a message (from the server) and process it.
Processing the message involves calling the receive
extensionsand the channellisteners.- Parameters:
message- the message received.promise- the promise notified of the receive processing
-
notifyListeners
protected void notifyListeners(Message.Mutable message)
-
notifyCallback
protected void notifyCallback(ClientSession.MessageListener callback, Message.Mutable message)
-
registerCallback
protected void registerCallback(String messageId, ClientSession.MessageListener callback)
-
unregisterCallback
protected ClientSession.MessageListener unregisterCallback(String messageId)
-
registerSubscriber
protected void registerSubscriber(String messageId, ClientSessionChannel.MessageListener subscriber)
-
unregisterSubscriber
protected ClientSessionChannel.MessageListener unregisterSubscriber(String messageId)
-
dump
public void dump(Appendable out, String indent) throws IOException
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-
-