App Class Reference

Object given to any 'client' application Give access to network, configuration, ... More...

#include <App.hh>

List of all members.

Public Member Functions

 App (lua_State *l)
void startServer ()
 Start a server, running on the same processus.
void connect ()
 Connect to the server.
void disconnect ()
 Disconnect from server.
int connectionStatus ()
 Get client's connection status to the server.
ApigetApi ()
 Get the api.
void process (bool block=false, bool do_poll=true)
 Process server/network/.
template<typename T >
getConf (const std::string &key) const
 Get a configuration value.
template<typename T >
void setConf (const std::string &key, const T &value)
 Set a configuration value.
void setConfInt (const std::string &key, const std::string &value)
 Set a configuration value.
void writeConf ()
 Write user defined values, set using 'setConf', on a file on the disk.
template<>
void setConf (const std::string &key, const std::string &value)
template<>
void setConf (const std::string &key, const int &value)
template<>
void setConf (const std::string &key, const bool &value)

Static Public Attributes

static const char className [] = "App"
static Luna< App >::RegType methods []

Detailed Description

Object given to any 'client' application Give access to network, configuration, ...


Member Function Documentation

void App::connect (  ) 

Connect to the server.

Host/Port used are the ones specified in configuration. This function always succeed, you should then poll status with 'connectionStatus'.

Referenced by sfmlgui::SFMLApp::run(), and CmdLineWrapper::run().

int App::connectionStatus (  ) 

Get client's connection status to the server.

Returns:
Current connection status. 0 -> not connected, 1 -> in progress, 2 -> connected
Todo:
FIXME: Should be an enum. Should handle the case where connection is not successful.

Referenced by sdlvisu::VisuApp::run(), sfmlgui::SFMLApp::run(), and CmdLineWrapper::run().

void App::disconnect (  ) 

Disconnect from server.

Todo:
FIXME: May not yet work.
Api * App::getApi (  ) 

Get the api.

Returns:
An api object.

Referenced by sdlvisu::VisuApp::run(), sfmlgui::SFMLApp::run(), and CmdLineWrapper::run().

bool App::getConf ( const std::string &  key  )  const [inline]

Get a configuration value.

Parameters:
key Configuration key (eg: client.connect_host)
Returns:
Configuration value. Type could be int, bool or std::string.

Referenced by sdlvisu::VisuApp::init(), and CmdLineWrapper::run().

void App::process ( bool  block = false,
bool  do_poll = true 
)

Process server/network/.

.. data

Parameters:
block If true, this function will block around 50ms. Use it if you don't have yourself a blocking function.
do_poll If true, this function won't poll packets for the client. Use it if you need to delay the GUI (for example, during an animation).

Referenced by sdlvisu::VisuApp::run(), sfmlgui::SFMLApp::run(), and CmdLineWrapper::run().

template<typename T >
void App::setConf ( const std::string &  key,
const T &  value 
) [inline]

Set a configuration value.

Parameters:
key Configuration key.
value Value to set (see getConf).

Referenced by sfmlgui::SFMLApp::run().

void App::setConfInt ( const std::string &  key,
const std::string &  value 
)

Set a configuration value.

Note:
Like setConf, but will save as an integer type (thus value is expected to be an integer)
void App::startServer (  ) 

Start a server, running on the same processus.

Listen port is 'server.listen_port' configuration item. You can then connect it using 'connect', on localhost:listen_port.

void App::writeConf (  ) 

Write user defined values, set using 'setConf', on a file on the disk.

Note:
This may or may not work. You should not care about the result.

Member Data Documentation

Luna< App >::RegType App::methods [static]
Initial value:
 {
  { 0, 0 }
}

The documentation for this class was generated from the following files:
Generated on Mon Apr 5 21:17:26 2010 for Stechec/TBT by  doxygen 1.6.3