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.

  • Constructor Details

    • AbstractClientSession

      protected AbstractClientSession()
  • Method Details

    • newMessageId

      protected String newMessageId()
    • addExtension

      public void addExtension(ClientSession.Extension extension)
      Specified by:
      addExtension in interface ClientSession
    • removeExtension

      public void removeExtension(ClientSession.Extension extension)
      Specified by:
      removeExtension in interface ClientSession
    • getExtensions

      public List<ClientSession.Extension> getExtensions()
      Specified by:
      getExtensions in interface 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

      protected abstract org.cometd.bayeux.ChannelId newChannelId(String channelId)
    • newChannel

      protected abstract AbstractClientSession.AbstractSessionChannel newChannel(org.cometd.bayeux.ChannelId channelId)
    • getChannel

      public ClientSessionChannel getChannel(String channelName)
      Specified by:
      getChannel in interface ClientSession
    • getChannel

      public ClientSessionChannel getChannel(org.cometd.bayeux.ChannelId channelId)
    • getChannels

    • startBatch

      public void startBatch()
      Specified by:
      startBatch in interface org.cometd.bayeux.Session
    • sendBatch

      protected abstract void sendBatch()
    • endBatch

      public boolean endBatch()
      Specified by:
      endBatch in interface org.cometd.bayeux.Session
    • batch

      public void batch(Runnable batch)
      Specified by:
      batch in interface org.cometd.bayeux.Session
    • isBatching

      protected boolean isBatching()
    • getAttribute

      public Object getAttribute(String name)
      Specified by:
      getAttribute in interface org.cometd.bayeux.Session
    • getAttributeNames

      public Set<String> getAttributeNames()
      Specified by:
      getAttributeNames in interface org.cometd.bayeux.Session
    • removeAttribute

      public Object removeAttribute(String name)
      Specified by:
      removeAttribute in interface org.cometd.bayeux.Session
    • setAttribute

      public void setAttribute(String name, Object value)
      Specified by:
      setAttribute in interface org.cometd.bayeux.Session
    • remoteCall

      public void remoteCall(String target, Object data, ClientSession.MessageListener callback)
      Specified by:
      remoteCall in interface 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 channel listeners.

      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

      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:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Throws:
      IOException