Class ActivityExtension

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

public class ActivityExtension
extends org.cometd.bayeux.server.BayeuxServer.Extension.Adapter

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 class  ActivityExtension.Activity
    The possible activity to monitor
    static class  ActivityExtension.SessionExtension
    Monitors the activity of a single ServerSession, disconnecting it when the max inactivity period is exceeded.

    Nested classes/interfaces inherited from interface org.cometd.bayeux.server.BayeuxServer.Extension

    org.cometd.bayeux.server.BayeuxServer.Extension.Adapter
  • 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
    ActivityExtension.Activity getActivity()  
    long getMaxInactivityPeriod()  
    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 org.cometd.bayeux.server.BayeuxServer.Extension.Adapter

    rcv, send, sendMeta

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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
      Overrides:
      rcvMeta in class org.cometd.bayeux.server.BayeuxServer.Extension.Adapter
    • 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