qi::ApplicationSession¶
ApplicationSession
is an application with an embedded auto-connected
Session
.
Summary¶
class qi::ApplicationSession
Functions (class qi::ApplicationSession)
Global Classes
Detailed Description¶
ApplicationSession
is meant to be instantiated in the main function. It works
pretty much like Application
but embeds a Session in it. The session is
connected when start
is called (or when run
is called if start
is never
called).
The session is automatically activated (in listening or connected mode) according to the arguments passed to the program.
ApplicationSession
also parses arguments, see qi application arguments.
See also
This class follows the logic of Application
.
Usage Example¶
#include <qi/applicationsession.hpp>
int main(int argc, char* argv[])
{
qi::ApplicationSession app(argc, argv);
app.start();
qi::SessionPtr session = app.session();
// do things with session->service() or session->registerService
// if you want to keep the program running
app.run();
}
Reference¶
qi::ApplicationSession Class Reference¶
Enumerations¶
-
enum
Option
¶ Name Value Brief Option_None
0 No option, this is the default behavior. Option_NoAutoExit
1 With this option the application won’t stop once the session is disconnected.
Public Functions¶
-
(int& argc, char**& argv, int opt, const Url& url)ApplicationSession
-
(const std::string& name, int& argc, char**& argv, int opt, const Url& url)ApplicationSession
-
(int& argc, char**& argv, const Config& defaultConfig)ApplicationSession
-
()~ApplicationSession
-
SessionPtr
()session
-
Url
()url
-
Url
()listenUrl
-
void
()start
-
void
()startSession
-
void
()run
Detailed Description¶
ApplicationSession is an application with an embedded session. The constructor has to be the first method called of the class to initialize the class. Be careful with the scope of the object, once the destructor is called, the session is destroyed as well.
Function Documentation¶
-
qi::ApplicationSession::
ApplicationSession
(int& argc, char**& argv, int opt = 0, const Url& url = "tcp://127.0.0.1:9559")¶ Brief:
Parameters: - argc – The number of arguments.
- argv – The array containing all the arguments given to the program.
- opt – Either ApplicationSession::Option_None or ApplicationSession::Option_NoAutoExit. The default behavior of ApplicationSession is to call stop() once the session gets disconnected.
- url – The default url used if no qi-url was found in the options.
ApplicationSession will check first if there is a qi-url given in argv, if not it will take the url in the constructor instead setting its url. If qi-listen-url is set the session will listen on the provided url.
-
qi::ApplicationSession::
ApplicationSession
(const std::string& name, int& argc, char**& argv, int opt = 0, const Url& url = "tcp://127.0.0.1:9559")¶
-
qi::ApplicationSession::
~ApplicationSession
()¶
-
SessionPtr
qi::ApplicationSession::
session
()¶ Brief:
Returns: The embedded session used by ApplicationSession.
-
Url
qi::ApplicationSession::
url
()¶ Brief:
Returns: The url used by ApplicationSession parsed on the command line by qi-url if specified, otherwise the default url given in the constructor.
-
Url
qi::ApplicationSession::
listenUrl
()¶ Brief:
Returns: The url used by ApplicationSession parsed on the command line by qi-listen-url, otherwise the default url given in the constructor.
-
void
qi::ApplicationSession::
start
()¶ Establishes the session’s connection and moreover starts listening if qi-listen-url was given. Deprecatedsince 2.5, use startSession instead