C++ API Library Reference  4.3.2-74-ge1d4cca
Classes | Public Functions | Public Static Functions | List of all members
CommandManager Class Referenceabstract

The CommandManager class provides methods to manage commands handlers on the I/O and UI threads, and to configure command filters. Instance members are thread-safe.

About Command Handlers
A command handler is a function executed by the service application upon receiving the relevant command from a client. In order for this to work, command handlers are registered with StateManager with a unique command name. This is how PureWeb knows which handler to fire for which command. Command handler registration is accomplished using AddIoHandler and AddUiHandler, which are part of this CommandManager class.
About Command Filters
Command filters are used to aggregate redundant input events into a single event, thereby reducing the number of commands automatically fired to the service application. The default service-side command filter aggregates view resize and ping events (command filters also exist for the clients, and by default these also aggregate mouse move and mouse wheel events). Since command filters work on commands automatically generated by PureWeb for input events, changing the defaults is rare.

Public Functions

virtual Collections::List< ResponseInfo > GetNextResponses (Guid sessionId)=0
 
virtual void Initialize (StateManager *pStateManager)=0
 
virtual void SessionConnected (Guid sessionId, Typeless const &command)=0
 
virtual void SessionDisconnected (Guid sessionId, Typeless const &command)=0
 
virtual void Uninitialize ()=0
 
Constructors and Destructors
 CommandManager ()
 
 ~CommandManager ()
 
Core Functions (most frequently used)
virtual CountedPtr< Util::ICommandFilterCommandFilter () const
 
virtual void AddIoHandler (String const &name, CommandHandler const &handler)
 
virtual void RemoveIoHandler (String const &name)
 
virtual void AddUiHandler (String const &name, CommandHandler const &handler)
 
virtual void RemoveUiHandler (String const &name)
 
Other Functions
virtual void SetCommandFilter (CountedPtr< Util::ICommandFilter > const &pFilter)
 
virtual void InjectCommand (Guid sessionId, String command, Typeless &parameters)
 

Public Static Functions

static Typeless NullCommand ()
 

Usage Description

void AddIoHandler ( String const &  name,
CommandHandler const &  handler 
)
virtual

Registers a handler with StateManager for the specified command name. The handler will be executed on the I/O thread.

Note
You can only have one handler for any given command. If you register two separate handlers for the same command, only the last one will be stored.

Parameters
nameThe name of the command that will fire the handler. The name that you use here when registering the handler will act as the command ID. This is the name that must be used in the client-side code when sending the command.
handlerThe handler function that will be executed when the command is received.

Implements ICommandManager.

void AddUiHandler ( String const &  name,
CommandHandler const &  handler 
)
virtual

Registers a handler with StateManager for the specified command name. The handler will be executed on the UI thread.

Note
You can only have one handler for any given command. If you register two separate handlers for the same command, only the last one will be stored.

Parameters
nameThe name of the command that will fire the handler. The name that you use here when registering the handler will act as the command ID. This is the name that must be used in the client-side code when sending the command.
handlerThe handler function that will be executed when the command is received.

Implements ICommandManager.

CountedPtr< Util::ICommandFilter > CommandFilter ( ) const
virtual

Returns the command filter class currently used by the service; defaults to DefaultCommandFilter.

Implements ICommandManager.

virtual Collections::List<ResponseInfo> GetNextResponses ( Guid  sessionId)
pure virtualinherited

Gets the next responses for the specified session.

Parameters
sessionIDThe session's unique identifer.
virtual void Initialize ( StateManager pStateManager)
pure virtualinherited

Initializes the plugin with the specified StateManager.

Parameters
stateManagerThe StateManager.

Implemented in ViewManager.

void InjectCommand ( Guid  sessionId,
String  command,
Typeless &  parameters 
)
virtual

Simulates a command from a client. This method is typically used for testing purposes.

Parameters
sessionIdThe unique identifier of the session to which the command applies.
commandThe name of the command, as registered with StateManager.
parametersThe parameters that the client would have included in the command.

Implements ICommandManager.

static Typeless NullCommand ( )
inlinestatic

Returns the NullCommand method, which is used with command filtering.

void RemoveIoHandler ( String const &  name)
virtual

Removes the handler for the specified command name from the I/O thread.

Parameters
nameThe name of the command for which the handler should be removed. This must be the same name as was used when the handler was first added using AddIoHandler.

Implements ICommandManager.

void RemoveUiHandler ( String const &  name)
virtual

Removes the handler for the specified command name from the UI thread.

Parameters
nameThe name of the command for which the handler should be removed. This must be the same name as was used when the handler was first added using AddUiHandler.

Implements ICommandManager.

virtual void SessionConnected ( Guid  sessionId,
Typeless const &  command 
)
pure virtualinherited

Indicates that the specified session is connected.

Parameters
sessionIdThe session's unique identifier.
commandThe command that was received causing the session to connect.
virtual void SessionDisconnected ( Guid  sessionId,
Typeless const &  command 
)
pure virtualinherited

Indicates that the specified session is disconnected.

Parameters
sessionIdThe session's unique identifier.
commandThe command that was received causing the session to disconnect.
void SetCommandFilter ( CountedPtr< Util::ICommandFilter > const &  pFilter)
virtual

Sets the service-side command filter class. For an example of such a class, see DefaultCommandFilter.

Parameters
pFilterThe name of the class to be used for filtering the commands automatically sent by PureWeb for input events.

Implements ICommandManager.

virtual void Uninitialize ( )
pure virtualinherited

Uninitializes the plugin.

Implemented in ViewManager.