Class ActivityExtension

  • All Implemented Interfaces:
    org.cometd.bayeux.server.BayeuxServer.Extension

    public class ActivityExtension
    extends java.lang.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 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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 java.lang.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 Detail

      • 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 Detail

      • 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