C# / .Net API Library Reference  4.3.2-74-ge1d4cca
Data Structures | Public Functions | Static Public Attributes | Properties
CommandManager Class Reference

The CommandManager class provides methods to manage command 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 using 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 by PureWeb 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

void AddIoHandler (string name, CommandHandler handler)
 
void AddUiHandler (string name, CommandHandler handler)
 
List< ResponseInfo > GetNextResponses (Guid sessionId)
 
void Initialize (StateManager stateManager)
 
void InjectCommand (Guid sessionId, string type, IDictionary< string, object > parameters)
 
void RemoveIoHandler (string name)
 
void RemoveUiHandler (string name)
 
void SessionConnected (Guid sessionId, XElement command)
 
void SessionDisconnected (Guid sessionId, XElement command)
 
void Uninitialize ()
 
Constructors and Destructors
 CommandManager ()
 

Static Public Attributes

static readonly XElement NullCommand = PureWeb.Util.CommandFilter.NullCommand
 

Properties

ICommandFilter CommandFilter [get, set]
 

Usage Description

void AddIoHandler ( string  name,
CommandHandler  handler 
)
inline

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  name,
CommandHandler  handler 
)
inline

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.

List<ResponseInfo> GetNextResponses ( Guid  sessionId)
inherited

Gets the next responses for the specified session.

Parameters
sessionIdThe unique identifier of the session.
void Initialize ( StateManager  stateManager)
inherited

Initializes the plugin with the specified StateManager.

Parameters
stateManagerThe StateManager.

Implemented in ViewManager.

void InjectCommand ( Guid  sessionId,
string  type,
IDictionary< string, object >  parameters 
)
inline

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.
typeThe name of the command, as registered with StateManager.
parametersThe parameters that the client would have included in the command.

Implements ICommandManager.

void RemoveIoHandler ( string  name)
inline

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  name)
inline

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.

void SessionConnected ( Guid  sessionId,
XElement  command 
)
inherited

Indicates that the specified session is connected.

Parameters
sessionIdThe session's unique identifier.
commandThe command that caused the connection.
void SessionDisconnected ( Guid  sessionId,
XElement  command 
)
inherited

Indicates that the specified session is disconnected.

Parameters
sessionIdThe session's unique identifer.
commandThe command that caused the disconnection.
void Uninitialize ( )
inherited

Uninitializes the plugin.

Implemented in ViewManager.

Field Documentation

readonly XElement NullCommand = PureWeb.Util.CommandFilter.NullCommand
static

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

Property Documentation

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