ApplicationSession
is an application with an embedded auto-connected
Session
.
Global Classes
class qi::ApplicationSession
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
.
#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();
}
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. |
ApplicationSession
(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
()session
() consturl
() constlistenUrl
() constallListenUrl
() conststart
()startSession
()run
()standAlone
()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.
qi::ApplicationSession::
ApplicationSession
(int& argc, char**& argv, int opt = 0, const Url& url = "tcp://127.0.0.1:9559")¶Brief:
Parameters: |
|
---|
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
(int& argc, char**& argv, const Config& defaultConfig)¶qi::ApplicationSession::
~ApplicationSession
()¶qi::ApplicationSession::
session
() const
¶Brief:
Returns: | The embedded session used by ApplicationSession. |
---|
qi::ApplicationSession::
url
() const
¶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. |
---|
qi::ApplicationSession::
listenUrl
() const
¶Brief:
Returns: | The url used by ApplicationSession parsed on the command line by qi-listen-url, otherwise the default url given in the constructor. |
---|
qi::ApplicationSession::
allListenUrl
() const
¶Brief:
Returns: | The urls used by ApplicationSession parsed on the command line by qi-listen-url, otherwise the default url given in the constructor. |
---|
qi::ApplicationSession::
start
()¶Establishes the session’s connection and moreover starts listening if qi-listen-url was given. Deprecatedsince 2.5, use startSession instead
qi::ApplicationSession::
startSession
()¶Establishes the session’s connection and moreover starts listening if qi-listen-url was given.
qi::ApplicationSession::
run
()¶Runs the application and automatically calls start() if it hasn’t been done yet.
qi::ApplicationSession::
standAlone
()¶Returns whether the ApplicationSession runs in standalone mode.