Class ActivityExtension

java.lang.Object
org.cometd.server.ext.ActivityExtension
All Implemented Interfaces:
org.cometd.bayeux.server.BayeuxServer.Extension

public class ActivityExtension extends Object implements org.cometd.bayeux.server.BayeuxServer.Extension

Monitors the activity of ServerSessions and disconnects them after a period of inactivity.

The inactivity of a particular ServerSession is determined in two ways:

  • Only the client is inactive, that is the client only sends periodic /meta/connect messages but no other messages, while the server may send messages to the client; this is configured via ActivityExtension.Activity.CLIENT
  • Both the client and the server are inactive, that is neither the client nor the server send messages apart the periodic /meta/connect messages; this is configured via ActivityExtension.Activity.CLIENT_SERVER

When the inactivity exceeds a configurable inactive period, the ServerSession is disconnected.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The possible activity to monitor
    static class 
    Monitors the activity of a single ServerSession, disconnecting it when the max inactivity period is exceeded.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ActivityExtension(ActivityExtension.Activity activity, long maxInactivityPeriod)
    Creates an ActivityExtension to be installed in the BayeuxServer
  • Method Summary

    Modifier and Type
    Method
    Description
     
    long
     
    protected org.cometd.bayeux.server.ServerSession.Extension
    newSessionExtension(org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage handshake)
    Creates a new ServerSession.Extension that monitors the activity of the given ServerSession
    boolean
    rcvMeta(org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage.Mutable message)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.cometd.bayeux.server.BayeuxServer.Extension

    incoming, outgoing, rcv, send, sendMeta
  • Constructor Details

    • ActivityExtension

      public ActivityExtension(ActivityExtension.Activity activity, long maxInactivityPeriod)
      Creates an ActivityExtension to be installed in the BayeuxServer
      Parameters:
      activity - the activity to monitor
      maxInactivityPeriod - the max inactivity period, in milliseconds
  • Method Details

    • getActivity

      public ActivityExtension.Activity getActivity()
      Returns:
      the activity that is being monitored by this extension
    • getMaxInactivityPeriod

      public long getMaxInactivityPeriod()
      Returns:
      the max inactivity period, in milliseconds
    • rcvMeta

      public boolean rcvMeta(org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage.Mutable message)
      Specified by:
      rcvMeta in interface org.cometd.bayeux.server.BayeuxServer.Extension
    • newSessionExtension

      protected org.cometd.bayeux.server.ServerSession.Extension newSessionExtension(org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage handshake)
      Creates a new ServerSession.Extension that monitors the activity of the given ServerSession
      Parameters:
      session - the ServerSession to monitor
      handshake - the handshake message
      Returns:
      a new ServerSession.Extension that monitors the ServerSession activity