Package org.cometd.server.ext
Class ActivityExtension
- java.lang.Object
-
- org.cometd.server.ext.ActivityExtension
-
- All Implemented Interfaces:
BayeuxServer.Extension
public class ActivityExtension extends Object implements BayeuxServer.Extension
Monitors the activity of
ServerSession
s 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 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/connect
messages; this is configured viaActivityExtension.Activity.CLIENT_SERVER
When the inactivity exceeds a configurable
inactive period
, theServerSession
isdisconnected
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ActivityExtension.Activity
The possible activity to monitorstatic class
ActivityExtension.SessionExtension
Monitors the activity of a singleServerSession
, disconnecting it when the max inactivity period is exceeded.-
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.BayeuxServer.Extension
BayeuxServer.Extension.Adapter
-
-
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.Activity
getActivity()
long
getMaxInactivityPeriod()
protected ServerSession.Extension
newSessionExtension(ServerSession session, ServerMessage handshake)
Creates a newServerSession.Extension
that monitors the activity of the givenServerSession
boolean
rcvMeta(ServerSession session, ServerMessage.Mutable message)
Blocking version ofBayeuxServer.Extension.incoming(ServerSession, ServerMessage.Mutable, Promise)
for meta messages.
-
-
-
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(ServerSession session, ServerMessage.Mutable message)
Description copied from interface:BayeuxServer.Extension
Blocking version of
BayeuxServer.Extension.incoming(ServerSession, ServerMessage.Mutable, Promise)
for meta messages.- Specified by:
rcvMeta
in interfaceBayeuxServer.Extension
- Parameters:
session
- the session that sent the messagemessage
- the incoming message- Returns:
- whether message processing should continue
-
newSessionExtension
protected ServerSession.Extension newSessionExtension(ServerSession session, ServerMessage handshake)
Creates a newServerSession.Extension
that monitors the activity of the givenServerSession
- Parameters:
session
- theServerSession
to monitorhandshake
- the handshake message- Returns:
- a new
ServerSession.Extension
that monitors theServerSession
activity
-
-