Package org.cometd.server.ext
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.AdapterMonitors the activity of
ServerSessions and disconnects them after a period of inactivity.The inactivity of a particular
ServerSessionis determined in two ways:- Only the client is inactive, that is the client only sends periodic
/meta/connectmessages but no other messages, while the server may send messages to the client; this is configured viaActivityExtension.Activity.CLIENT - Both the client and the server are inactive, that is neither the client nor the server
send messages apart the periodic
/meta/connectmessages; this is configured viaActivityExtension.Activity.CLIENT_SERVER
When the inactivity exceeds a configurable
inactive period, theServerSessionisdisconnected.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classActivityExtension.ActivityThe possible activity to monitorstatic classActivityExtension.SessionExtensionMonitors the activity of a singleServerSession, 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 theBayeuxServer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActivityExtension.ActivitygetActivity()longgetMaxInactivityPeriod()protected org.cometd.bayeux.server.ServerSession.ExtensionnewSessionExtension(org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage handshake)Creates a newServerSession.Extensionthat monitors the activity of the givenServerSessionbooleanrcvMeta(org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage.Mutable message)
-
-
-
Constructor Detail
-
ActivityExtension
public ActivityExtension(ActivityExtension.Activity activity, long maxInactivityPeriod)
Creates an ActivityExtension to be installed in theBayeuxServer- Parameters:
activity- the activity to monitormaxInactivityPeriod- the max inactivity period, in milliseconds
-
-
Method Detail
-
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:
rcvMetain interfaceorg.cometd.bayeux.server.BayeuxServer.Extension- Overrides:
rcvMetain classorg.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 newServerSession.Extensionthat monitors the activity of the givenServerSession- Parameters:
session- theServerSessionto monitorhandshake- the handshake message- Returns:
- a new
ServerSession.Extensionthat monitors theServerSessionactivity
-
-