C# / .Net API Library Reference
Public Functions | Data Fields | Properties | Events
StateManager Class Reference

The StateManager class manages the service application using a collection of plugins.

Public Functions

XmlStateLock LockAppState ()
 
void Start ()
 
void Stop ()
 
bool TryLockAppState (TimeSpan timeout, out XmlStateLock stateLock)
 
Constructors and Destructors
Note
This constructor is deprecated as of PureWeb 5.0. The application name will now be provided through the "service-manager" service. Use the default constructor instead.
 StateManager (string applicationName, IDispatcher uiDispatcher)
 

Data Fields

EventHandler< RequestReceivedEventArgsRequestReceived
 
EventHandler< ResponsesReadyEventArgs > ResponsesReady
 

Properties

Guid ApplicationId [get, set]
 
string ApplicationName [get]
 
ICommandManager CommandManager [get]
 
static StateManager Instance [get]
 
bool IsStarted [get]
 
bool IsStopping [get]
 
IRequestManager RequestManager [get]
 
IResourceManager ResourceManager [get]
 
string this[string path] [get, set]
 
IViewManager ViewManager [get]
 

Events

EventHandler Initialized
 
EventHandler Uninitialized
 

Usage Description

XmlStateLock LockAppState ( )
inline

Acquires a lock on the application state.

In multi-client environments, the application state shouldn't be assumed to be perfectly synchronized, due to network latency or other factors. For this reason, it is possible to request a lock on StateManager, which ensures that no changes to the application state take place while the lock is held. This is needed, for example, if you want to perform atomic changes to multiple paths of the application state tree.

void Start ( )
inline

Starts this instance of the StateManager. This connects your service application to the "app-server" service, and makes it ready to receive client connections.

void Stop ( )
inline

Stops this instance of StateManager. This disconnects your service application from the "app-server" service, and makes it unavailable to receive client connections. The Uninitialized event will fire when the process is complete.

bool TryLockAppState ( TimeSpan  timeout,
out XmlStateLock  stateLock 
)
inline

Attempts to acquire a lock on application state before the specified timeout elapses. Returns true if the lock is acquired, or false otherwise.

Parameters
timeoutThe maximum amount of time that StateManager will wait to acquire the lock.
stateLockThe lock to be acquired.

Field Documentation

EventHandler<RequestReceivedEventArgs> RequestReceived

This event is fired when StateManager receives a request.

EventHandler<ResponsesReadyEventArgs> ResponsesReady

This event is fired when StateManager has session responses ready to send.

Property Documentation

Guid ApplicationId
getset

Gets the unique identifier of this instance of StateManager. This method is for information purposes only. The ID is automatically assigned by PureWeb.

string ApplicationName
get

Gets the name of this instance of StateManager. This method is for information purposes only. The name comes from the service's json configuration file.

Gets a reference to the CommandManager class.

StateManager Instance
staticget

Gets the one and only StateManager instance. Will be null if the StateManager is not yet constructed.

bool IsStarted
get

Gets a Boolean value indicating whether this instance of StateManager is started. This method is for information purposes only, and can be useful when testing or troubleshooting the application.

bool IsStopping
get

Gets a Boolean value indicating whether this instance of StateManager is stopping. This method is for information purposes only, and can be useful when testing or troubleshooting the application.

Gets a reference to the RequestManager class.

Gets a reference to the ResourceManager class.

string this[string path]
getset

Gets or sets the application state value at the specified path.

Gets a reference to the ViewManager class.

Event Documentation

EventHandler Initialized

This event is fired once StateManager is initialized.

EventHandler Uninitialized

This event is fired once StateManager is uninitialized.