Package org.cometd.common
Class AbstractClientSession
java.lang.Object
org.cometd.common.AbstractClientSession
- All Implemented Interfaces:
ClientSession,org.cometd.bayeux.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.MessageListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainer -
Field Summary
Fields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractClientSession() -
Method Summary
Modifier and Type Method Description voidaddExtension(ClientSession.Extension extension)voidbatch(Runnable batch)voiddump(Appendable out, String indent)booleanendBatch()protected voidextendIncoming(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Boolean> promise)protected voidextendOutgoing(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Boolean> promise)ObjectgetAttribute(String name)Set<String>getAttributeNames()ClientSessionChannelgetChannel(String channelName)ClientSessionChannelgetChannel(org.cometd.bayeux.ChannelId channelId)protected ConcurrentMap<String,AbstractClientSession.AbstractSessionChannel>getChannels()List<ClientSession.Extension>getExtensions()protected booleanisBatching()protected abstract AbstractClientSession.AbstractSessionChannelnewChannel(org.cometd.bayeux.ChannelId channelId)protected abstract org.cometd.bayeux.ChannelIdnewChannelId(String channelId)protected org.cometd.bayeux.Message.MutablenewMessage()protected StringnewMessageId()protected voidnotifyCallback(ClientSession.MessageListener callback, org.cometd.bayeux.Message.Mutable message)protected voidnotifyListeners(org.cometd.bayeux.Message.Mutable message)voidreceive(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Void> promise)Receives a message (from the server) and process it.protected voidregisterCallback(String messageId, ClientSession.MessageListener callback)protected voidregisterSubscriber(String messageId, ClientSessionChannel.MessageListener subscriber)voidremoteCall(String target, Object data, ClientSession.MessageListener callback)ObjectremoveAttribute(String name)voidremoveExtension(ClientSession.Extension extension)protected voidresetSubscriptions()protected abstract voidsend(org.cometd.bayeux.Message.Mutable message)protected abstract voidsendBatch()voidsetAttribute(String name, Object value)voidstartBatch()protected ClientSession.MessageListenerunregisterCallback(String messageId)protected ClientSessionChannel.MessageListenerunregisterSubscriber(String messageId)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cometd.bayeux.client.ClientSession
disconnect, disconnect, handshake, handshake, handshakeMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dump, dumpSelfMethods inherited from interface org.cometd.bayeux.Session
getId, isConnected, isHandshook
-
Constructor Details
-
AbstractClientSession
protected AbstractClientSession()
-
-
Method Details
-
newMessageId
-
addExtension
- Specified by:
addExtensionin interfaceClientSession
-
removeExtension
- Specified by:
removeExtensionin interfaceClientSession
-
getExtensions
- Specified by:
getExtensionsin interfaceClientSession
-
extendOutgoing
protected void extendOutgoing(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Boolean> promise) -
extendIncoming
protected void extendIncoming(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<Boolean> promise) -
newChannelId
-
newChannel
protected abstract AbstractClientSession.AbstractSessionChannel newChannel(org.cometd.bayeux.ChannelId channelId) -
getChannel
- Specified by:
getChannelin interfaceClientSession
-
getChannel
-
getChannels
-
startBatch
public void startBatch()- Specified by:
startBatchin interfaceorg.cometd.bayeux.Session
-
sendBatch
protected abstract void sendBatch() -
endBatch
public boolean endBatch()- Specified by:
endBatchin interfaceorg.cometd.bayeux.Session
-
batch
- Specified by:
batchin interfaceorg.cometd.bayeux.Session
-
isBatching
protected boolean isBatching() -
getAttribute
- Specified by:
getAttributein interfaceorg.cometd.bayeux.Session
-
getAttributeNames
- Specified by:
getAttributeNamesin interfaceorg.cometd.bayeux.Session
-
removeAttribute
- Specified by:
removeAttributein interfaceorg.cometd.bayeux.Session
-
setAttribute
- Specified by:
setAttributein interfaceorg.cometd.bayeux.Session
-
remoteCall
- Specified by:
remoteCallin interfaceClientSession
-
send
protected abstract void send(org.cometd.bayeux.Message.Mutable message) -
newMessage
protected org.cometd.bayeux.Message.Mutable newMessage() -
resetSubscriptions
protected void resetSubscriptions() -
receive
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
extensionsand the channellisteners.- Parameters:
message- the message received.promise- the promise notified of the receive processing
-
notifyListeners
protected void notifyListeners(org.cometd.bayeux.Message.Mutable message) -
notifyCallback
protected void notifyCallback(ClientSession.MessageListener callback, org.cometd.bayeux.Message.Mutable message) -
registerCallback
-
unregisterCallback
-
registerSubscriber
protected void registerSubscriber(String messageId, ClientSessionChannel.MessageListener subscriber) -
unregisterSubscriber
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-