VoiceMan
Public Member Functions
MainLoop Class Reference

Main class to manage client connections. More...

List of all members.

Public Member Functions

 MainLoop (const ClientFactory &clientFactory, ClientList &clients, size_t maxClients, AbstractClientDataHandler &clientDataHandler, AbstractSignalHandler &signalHandler, AbstractExecutorOutput &executorOutput, bool &terminationFlag)
 The constructor.
void run (const SocketList &sockets, sigset_t *sigMask)
 The main method to execute loop and handle data.

Detailed Description

This class manages clients connections and handles any data received from clients. It contains main pselect() system call to wait new data or new connections. This class uses list of currently accepted clients but all clients must be closed explicitly on this classs destruction. It is not recommended to have two instances of this class because of behavior may depend on process signal handling. Also this class handles system signal checking and processing data received back from the executor process.

See also:
Client ExecutorInterface VoicemanServer

Constructor & Destructor Documentation

MainLoop::MainLoop ( const ClientFactory clientFactory,
ClientList &  clients,
size_t  maxClients,
AbstractClientDataHandler clientDataHandler,
AbstractSignalHandler signalHandler,
AbstractExecutorOutput executorOutput,
bool &  terminationFlag 
) [inline]
Parameters:
[in]clientFactoryThe reference to a factory for new client object creation
[in]clientsThe list to store connected client set
[in]maxClientsThe maximum number of accepted clients (0 - not limited)
[in]clientDataHandlerThe reference to a object to handle data read from client connection
[in]signalHandlerThe reference to a object to handle registered signals
[in]executorOutputThe reference to an object to provide information about executor output streams
[in]terminationFlagThe reference to termination flag variable

Member Function Documentation

void MainLoop::run ( const SocketList &  sockets,
sigset_t *  sigMask 
)

Use this method to launch main loop and start client accepting.

Parameters:
[in]socketsThe list of sockets objects to listen
[in]sigMaskThe sigmal mask to operate with