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.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 a ClientSession.

    Nested classes/interfaces inherited from interface org.cometd.bayeux.client.ClientSession

    org.cometd.bayeux.client.ClientSession.Extension, org.cometd.bayeux.client.ClientSession.MessageListener
  • Field Summary

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    KEY
  • 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​(java.lang.Runnable batch)  
    void dump​(java.lang.Appendable out, java.lang.String indent)  
    boolean endBatch()  
    protected void extendIncoming​(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)  
    protected void extendOutgoing​(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)  
    java.lang.Object getAttribute​(java.lang.String name)  
    java.util.Set<java.lang.String> getAttributeNames()  
    org.cometd.bayeux.client.ClientSessionChannel getChannel​(java.lang.String channelName)  
    org.cometd.bayeux.client.ClientSessionChannel getChannel​(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 boolean isBatching()  
    protected abstract AbstractClientSession.AbstractSessionChannel newChannel​(org.cometd.bayeux.ChannelId channelId)  
    protected abstract org.cometd.bayeux.ChannelId newChannelId​(java.lang.String channelId)  
    protected org.cometd.bayeux.Message.Mutable newMessage()  
    protected java.lang.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<java.lang.Void> promise)
    Receives a message (from the server) and process it.
    protected void registerCallback​(java.lang.String messageId, org.cometd.bayeux.client.ClientSession.MessageListener callback)  
    protected void registerSubscriber​(java.lang.String messageId, org.cometd.bayeux.client.ClientSessionChannel.MessageListener subscriber)  
    void remoteCall​(java.lang.String target, java.lang.Object data, org.cometd.bayeux.client.ClientSession.MessageListener callback)  
    java.lang.Object removeAttribute​(java.lang.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​(java.lang.String name, java.lang.Object value)  
    void startBatch()  
    protected org.cometd.bayeux.client.ClientSession.MessageListener unregisterCallback​(java.lang.String messageId)  
    protected org.cometd.bayeux.client.ClientSessionChannel.MessageListener unregisterSubscriber​(java.lang.String messageId)  

    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.eclipse.jetty.util.component.Dumpable

    dump, dumpSelf

    Methods inherited from interface org.cometd.bayeux.Session

    getId, isConnected, isHandshook
  • Constructor Details

  • Method Details

    • newMessageId

      protected java.lang.String newMessageId()
    • addExtension

      public void addExtension​(org.cometd.bayeux.client.ClientSession.Extension extension)
      Specified by:
      addExtension in interface org.cometd.bayeux.client.ClientSession
    • removeExtension

      public void removeExtension​(org.cometd.bayeux.client.ClientSession.Extension extension)
      Specified by:
      removeExtension in interface org.cometd.bayeux.client.ClientSession
    • getExtensions

      public java.util.List<org.cometd.bayeux.client.ClientSession.Extension> getExtensions()
      Specified by:
      getExtensions in interface org.cometd.bayeux.client.ClientSession
    • extendOutgoing

      protected void extendOutgoing​(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
    • extendIncoming

      protected void extendIncoming​(org.cometd.bayeux.Message.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
    • 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:
      getChannel in interface org.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:
      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​(java.lang.Runnable batch)
      Specified by:
      batch in interface org.cometd.bayeux.Session
    • isBatching

      protected boolean isBatching()
    • getAttribute

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

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

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

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

      public void remoteCall​(java.lang.String target, java.lang.Object data, org.cometd.bayeux.client.ClientSession.MessageListener callback)
      Specified by:
      remoteCall in interface org.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<java.lang.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​(org.cometd.bayeux.client.ClientSession.MessageListener callback, org.cometd.bayeux.Message.Mutable message)
    • registerCallback

      protected void registerCallback​(java.lang.String messageId, org.cometd.bayeux.client.ClientSession.MessageListener callback)
    • unregisterCallback

      protected org.cometd.bayeux.client.ClientSession.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 void dump​(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Throws:
      java.io.IOException