Package org.cometd.common
Class AbstractClientSession
- java.lang.Object
-
- org.cometd.common.AbstractClientSession
-
- All Implemented Interfaces:
org.cometd.bayeux.client.ClientSession,org.cometd.bayeux.Session,org.eclipse.jetty.util.component.Dumpable
public abstract class AbstractClientSession extends java.lang.Object implements org.cometd.bayeux.client.ClientSession, org.eclipse.jetty.util.component.DumpablePartial 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.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractClientSession()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddExtension(org.cometd.bayeux.client.ClientSession.Extension extension)voidbatch(java.lang.Runnable batch)java.lang.Stringdump()voiddump(java.lang.Appendable out, java.lang.String indent)booleanendBatch()protected booleanextendRcv(org.cometd.bayeux.Message.Mutable message)protected booleanextendSend(org.cometd.bayeux.Message.Mutable message)java.lang.ObjectgetAttribute(java.lang.String name)java.util.Set<java.lang.String>getAttributeNames()org.cometd.bayeux.client.ClientSessionChannelgetChannel(java.lang.String channelName)org.cometd.bayeux.client.ClientSessionChannelgetChannel(org.cometd.bayeux.ChannelId channelId)protected java.util.concurrent.ConcurrentMap<java.lang.String,AbstractClientSession.AbstractSessionChannel>getChannels()java.util.List<org.cometd.bayeux.client.ClientSession.Extension>getExtensions()protected booleanisBatching()protected abstract AbstractClientSession.AbstractSessionChannelnewChannel(org.cometd.bayeux.ChannelId channelId)protected abstract org.cometd.bayeux.ChannelIdnewChannelId(java.lang.String channelId)protected org.cometd.bayeux.Message.MutablenewMessage()protected java.lang.StringnewMessageId()protected voidnotifyListener(org.cometd.bayeux.client.ClientSessionChannel.MessageListener listener, org.cometd.bayeux.Message.Mutable message)protected voidnotifyListeners(org.cometd.bayeux.Message.Mutable message)voidreceive(org.cometd.bayeux.Message.Mutable message)Receives a message (from the server) and process it.protected voidregisterCallback(java.lang.String messageId, org.cometd.bayeux.client.ClientSessionChannel.MessageListener callback)protected voidregisterSubscriber(java.lang.String messageId, org.cometd.bayeux.client.ClientSessionChannel.MessageListener subscriber)voidremoteCall(java.lang.String target, java.lang.Object data, org.cometd.bayeux.client.ClientSession.MessageListener callback)java.lang.ObjectremoveAttribute(java.lang.String name)voidremoveExtension(org.cometd.bayeux.client.ClientSession.Extension extension)protected voidresetSubscriptions()protected abstract voidsend(org.cometd.bayeux.Message.Mutable message)protected abstract voidsendBatch()voidsetAttribute(java.lang.String name, java.lang.Object value)voidstartBatch()protected org.cometd.bayeux.client.ClientSessionChannel.MessageListenerunregisterCallback(java.lang.String messageId)protected org.cometd.bayeux.client.ClientSessionChannel.MessageListenerunregisterSubscriber(java.lang.String messageId)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
newMessageId
protected java.lang.String newMessageId()
-
addExtension
public void addExtension(org.cometd.bayeux.client.ClientSession.Extension extension)
- Specified by:
addExtensionin interfaceorg.cometd.bayeux.client.ClientSession
-
removeExtension
public void removeExtension(org.cometd.bayeux.client.ClientSession.Extension extension)
- Specified by:
removeExtensionin interfaceorg.cometd.bayeux.client.ClientSession
-
getExtensions
public java.util.List<org.cometd.bayeux.client.ClientSession.Extension> getExtensions()
- Specified by:
getExtensionsin interfaceorg.cometd.bayeux.client.ClientSession
-
extendSend
protected boolean extendSend(org.cometd.bayeux.Message.Mutable message)
-
extendRcv
protected boolean extendRcv(org.cometd.bayeux.Message.Mutable message)
-
newChannelId
protected abstract org.cometd.bayeux.ChannelId newChannelId(java.lang.String channelId)
-
newChannel
protected abstract AbstractClientSession.AbstractSessionChannel newChannel(org.cometd.bayeux.ChannelId channelId)
-
getChannel
public org.cometd.bayeux.client.ClientSessionChannel getChannel(java.lang.String channelName)
- Specified by:
getChannelin interfaceorg.cometd.bayeux.client.ClientSession
-
getChannel
public org.cometd.bayeux.client.ClientSessionChannel getChannel(org.cometd.bayeux.ChannelId channelId)
-
getChannels
protected java.util.concurrent.ConcurrentMap<java.lang.String,AbstractClientSession.AbstractSessionChannel> 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
public void batch(java.lang.Runnable batch)
- Specified by:
batchin interfaceorg.cometd.bayeux.Session
-
isBatching
protected boolean isBatching()
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttributein interfaceorg.cometd.bayeux.Session
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceorg.cometd.bayeux.Session
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
- Specified by:
removeAttributein interfaceorg.cometd.bayeux.Session
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)- Specified by:
setAttributein interfaceorg.cometd.bayeux.Session
-
remoteCall
public void remoteCall(java.lang.String target, java.lang.Object data, org.cometd.bayeux.client.ClientSession.MessageListener callback)- Specified by:
remoteCallin interfaceorg.cometd.bayeux.client.ClientSession
-
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)
Receives a message (from the server) and process it.
Processing the message involves calling the receive
extensionsand the channellisteners.- Parameters:
message- the message received.
-
notifyListeners
protected void notifyListeners(org.cometd.bayeux.Message.Mutable message)
-
notifyListener
protected void notifyListener(org.cometd.bayeux.client.ClientSessionChannel.MessageListener listener, org.cometd.bayeux.Message.Mutable message)
-
registerCallback
protected void registerCallback(java.lang.String messageId, org.cometd.bayeux.client.ClientSessionChannel.MessageListener callback)
-
unregisterCallback
protected org.cometd.bayeux.client.ClientSessionChannel.MessageListener unregisterCallback(java.lang.String messageId)
-
registerSubscriber
protected void registerSubscriber(java.lang.String messageId, org.cometd.bayeux.client.ClientSessionChannel.MessageListener subscriber)
-
unregisterSubscriber
protected org.cometd.bayeux.client.ClientSessionChannel.MessageListener unregisterSubscriber(java.lang.String messageId)
-
dump
public java.lang.String dump()
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
java.io.IOException
-
-