C++ API Library Reference  4.3.2-74-ge1d4cca
Public Functions | List of all members
StateManagerServer Class Reference

The StateManagerServer is the singleton class used to communicate with the PureWeb server. It provides methods to start and stop the application, and to implement an input and output thread between the service and its client(s).

Public Functions

void InjectRequest (RequestInfo const &request)
 
CountedPtr< IInputStreamLoggerInputStreamLogger () const
 
CountedPtr< IOutputStreamLoggerOutputStreamLogger () const
 
void SetInputStreamLogger (CountedPtr< IInputStreamLogger > const &pLogger)
 
void SetOutputStreamLogger (CountedPtr< IOutputStreamLogger > const &pLogger)
 
void Start (StateManager *pStateManager, CSI::String hostnameOrAddress, int port)
 
void Start (StateManager *pStateManager, CSI::Net::IPAddress address, int port)
 
void Start (StateManager *pStateManager)
 
Collections::Map< CSI::String, CSI::StringStartupParameters () const
 
bool Stop (TimeSpan timeout=TimeSpan::Zero())
 
Constructors and Destructors
 StateManagerServer (void)
 
virtual ~StateManagerServer (void)
 
Events
 DEFINE_EVENT (ShutdownRequested, StateManagerServer &, EmptyEventArgs)
 
 DEFINE_EVENT (Stopped, StateManagerServer &, EmptyEventArgs)
 

Usage Description

DEFINE_EVENT ( ShutdownRequested  ,
StateManagerServer ,
EmptyEventArgs   
)

This event is fired when the StateManagerServer disconnects from the PureWeb server. It may be fired from the caller thread, and there may be in-progress responses and/or requests when this event is fired.

DEFINE_EVENT ( Stopped  ,
StateManagerServer ,
EmptyEventArgs   
)

This event is fired when StateManager::Stop has been invoked (but not necessarily completed). At this point, no more requests will be dispatched, and no more responses will be sent. This event may be fired from the caller thread.

void InjectRequest ( RequestInfo const &  request)

Simulates a client-side request. This method is typically used for testing purposes.

The request is made to StateManager on the calling thread. Does not catch any exceptions thrown by any request handlers. There is no interlocking with the input thread, so requests may be handled concurrently with requests made via the input thread.

CountedPtr< IInputStreamLogger > InputStreamLogger ( ) const

Gets a constant reference to the logger used for input stream logging.

CountedPtr< IOutputStreamLogger > OutputStreamLogger ( ) const

Gets a constant reference to the logger user for output stream logging.

void SetInputStreamLogger ( CountedPtr< IInputStreamLogger > const &  pLogger)

Sets the logger used for input stream logging. Will throw an InvalidOperationException if StateManagerServer is already started. Any errors that occur while writing to the input stream log may cause the input thread to behave in an undefined fashion.

void SetOutputStreamLogger ( CountedPtr< IOutputStreamLogger > const &  pLogger)

Sets the logger used for output stream logging. Will throw an InvalidOperationException if StateManagerServer is already started. Any errors that occur while writing to the output stream log may cause the output thread to behave in an undefined fashion.

void Start ( StateManager pStateManager,
CSI::String  hostnameOrAddress,
int  port 
)

Initiates the process of starting StateManagerServer at the specified hostname and port, and returns immediately.

Parameters
pStateManagerThe StateManager to start.
hostnameOrAddressThe hostname or address of the PureWeb server, expressed as a string.
portThe port to connect on.
void Start ( StateManager pStateManager,
CSI::Net::IPAddress  address,
int  port 
)

Initiates the process of starting StateManagerServer at the specified IP address and port, and returns immediately.

Parameters
pStateManagerThe StateManager to start.
addressThe IP address of the PureWeb server.
portThe port to connect on.
void Start ( StateManager pStateManager)

Initiates the process of starting StateManagerServer on localhost at PUREWEB_PORT, and returns immediately.

Map< String, String > StartupParameters ( ) const

Gets the list of the key-value pairs passed as query strings in the startup URL. This is for information purposes only, and may be useful when testing or troubleshooting.

bool Stop ( TimeSpan  timeout = TimeSpan::Zero())

Initiates the process of stopping StateManagerServer, and returns after the specified timeout interval.

Returns true if all server threads have been succesfully stopped before the timeout period elapses.