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 Object implements org.cometd.bayeux.client.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 class
AbstractClientSession.AbstractSessionChannel
A channel scoped to aClientSession
. -
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractClientSession()
-
Method Summary
Modifier and Type Method Description void
addExtension(org.cometd.bayeux.client.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()
org.cometd.bayeux.client.ClientSessionChannel
getChannel(String channelName)
org.cometd.bayeux.client.ClientSessionChannel
getChannel(org.cometd.bayeux.ChannelId channelId)
protected ConcurrentMap<String,AbstractClientSession.AbstractSessionChannel>
getChannels()
List<org.cometd.bayeux.client.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(org.cometd.bayeux.client.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, org.cometd.bayeux.client.ClientSession.MessageListener callback)
protected void
registerSubscriber(String messageId, org.cometd.bayeux.client.ClientSessionChannel.MessageListener subscriber)
void
remoteCall(String target, Object data, org.cometd.bayeux.client.ClientSession.MessageListener callback)
Object
removeAttribute(String name)
void
removeExtension(org.cometd.bayeux.client.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 org.cometd.bayeux.client.ClientSession.MessageListener
unregisterCallback(String messageId)
protected org.cometd.bayeux.client.ClientSessionChannel.MessageListener
unregisterSubscriber(String messageId)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AbstractClientSession
protected AbstractClientSession()
-
-
Method Details
-
newMessageId
-
addExtension
public void addExtension(org.cometd.bayeux.client.ClientSession.Extension extension)- Specified by:
addExtension
in interfaceorg.cometd.bayeux.client.ClientSession
-
removeExtension
public void removeExtension(org.cometd.bayeux.client.ClientSession.Extension extension)- Specified by:
removeExtension
in interfaceorg.cometd.bayeux.client.ClientSession
-
getExtensions
- Specified by:
getExtensions
in interfaceorg.cometd.bayeux.client.ClientSession
-
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:
getChannel
in interfaceorg.cometd.bayeux.client.ClientSession
-
getChannel
public org.cometd.bayeux.client.ClientSessionChannel getChannel(org.cometd.bayeux.ChannelId channelId) -
getChannels
-
startBatch
public void startBatch()- Specified by:
startBatch
in interfaceorg.cometd.bayeux.Session
-
sendBatch
protected abstract void sendBatch() -
endBatch
public boolean endBatch()- Specified by:
endBatch
in interfaceorg.cometd.bayeux.Session
-
batch
- Specified by:
batch
in interfaceorg.cometd.bayeux.Session
-
isBatching
protected boolean isBatching() -
getAttribute
- Specified by:
getAttribute
in interfaceorg.cometd.bayeux.Session
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceorg.cometd.bayeux.Session
-
removeAttribute
- Specified by:
removeAttribute
in interfaceorg.cometd.bayeux.Session
-
setAttribute
- Specified by:
setAttribute
in interfaceorg.cometd.bayeux.Session
-
remoteCall
public void remoteCall(String target, Object data, org.cometd.bayeux.client.ClientSession.MessageListener callback)- Specified by:
remoteCall
in 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, 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 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(org.cometd.bayeux.client.ClientSession.MessageListener callback, org.cometd.bayeux.Message.Mutable message) -
registerCallback
protected void registerCallback(String messageId, org.cometd.bayeux.client.ClientSession.MessageListener callback) -
unregisterCallback
protected org.cometd.bayeux.client.ClientSession.MessageListener unregisterCallback(String messageId) -
registerSubscriber
protected void registerSubscriber(String messageId, org.cometd.bayeux.client.ClientSessionChannel.MessageListener subscriber) -
unregisterSubscriber
protected org.cometd.bayeux.client.ClientSessionChannel.MessageListener unregisterSubscriber(String messageId) -
dump
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
- Throws:
IOException
-