SoftBank Robotics documentation What's new in NAOqi 2.8?

qi::Session

A session is what allows you to connect services together locally or over the network. They can be used as server or client and can register or obtain services (on all sides, even in multi-client). You can read the guides to register a service and get a service.

Reference

qi::Session Class Reference

Introduction

More...

#include <qi/session.hpp>
  • Inherits: noncopyable, boost::enable_shared_from_this< Session >

Enumerations

enum ServiceLocality
Name Value Brief
ServiceLocality_All 0
ServiceLocality_Local 1
ServiceLocality_Remote 2

Public Signals

qi::Signal<unsigned int, std::string> serviceRegistered
qi::Signal<unsigned int, std::string> serviceUnregistered
qi::Signal connected
qi::Signal<std::string> disconnected

Public Functions

Session(bool enforceAuthentication, SessionConfig config)
Session(SessionConfig defaultConfig)
~Session()
const SessionConfig& config() const
qi::FutureSync<void> connect()
qi::FutureSync<void> connect(const char* serviceDirectoryURL)
qi::FutureSync<void> connect(const std::string& serviceDirectoryURL)
qi::FutureSync<void> connect(const qi::Url& serviceDirectoryURL)
bool isConnected() const
qi::Url url() const
qi::FutureSync<std::vector<ServiceInfo>> services(ServiceLocality locality)
qi::FutureSync<qi::AnyObject> service(const std::string& name)
qi::FutureSync<qi::AnyObject> service(const std::string& name, qi::MilliSeconds timeout)
qi::FutureSync<qi::AnyObject> service(const std::string& name, const std::string& protocol)
qi::FutureSync<qi::AnyObject> service(const std::string& name, const std::string& protocol, qi::MilliSeconds timeout)
qi::FutureSync<void> listen()
qi::FutureSync<void> listen(const qi::Url& address)
qi::FutureSync<void> listen(const std::vector<qi::Url>& addresses)
std::vector<qi::Url> endpoints() const
bool setIdentity(const std::string& key, const std::string& crt)
qi::FutureSync<void> close()
qi::FutureSync<void> listenStandalone()
qi::FutureSync<void> listenStandalone(const qi::Url& address)
qi::FutureSync<void> listenStandalone(const std::vector<qi::Url>& addresses)
qi::FutureSync<unsigned int> registerService(const std::string& name, AnyObject object)
qi::FutureSync<void> unregisterService(unsigned int serviceId)
void setAuthProviderFactory(AuthProviderFactoryPtr)
void setClientAuthenticatorFactory(ClientAuthenticatorFactoryPtr)
qi::FutureSync<unsigned int> loadService(const std::string& moduleName, const std::string& renameModule, const AnyReferenceVector& args)
template<typename T>
qi::FutureSync<T> callModule(const std::string& moduleName, const AnyReferenceVector& args)
FutureSync<void> waitForService(const std::string& servicename, MilliSeconds timeout)
qi::FutureSync<void> waitForService(const std::string& service)

Public Static Functions

const char* serviceDirectoryServiceName()
qi::MilliSeconds defaultServiceTimeout()
MilliSeconds defaultWaitForServiceTimeout()

Detailed Description

A Session allows you to interconnect services on the same machine or over the network.

Signals Documentation

qi::Signal<unsigned int, std::string> qi::Session::serviceRegistered
qi::Signal<unsigned int, std::string> qi::Session::serviceUnregistered
qi::Signal qi::Session::connected
qi::Signal<std::string> qi::Session::disconnected

Function Documentation

static const char* qi::Session::serviceDirectoryServiceName()
static qi::MilliSeconds qi::Session::defaultServiceTimeout()
static MilliSeconds qi::Session::defaultWaitForServiceTimeout()
qi::Session::Session(bool enforceAuthentication = false, SessionConfig config = {})
qi::Session::Session(SessionConfig defaultConfig)
qi::Session::~Session()
const SessionConfig& qi::Session::config() const
qi::FutureSync<void> qi::Session::connect()

Uses the connection URL from the configuration or the hardcoded default connect URL if the first one isn’t set.

qi::FutureSync<void> qi::Session::connect(const char* serviceDirectoryURL)

Ignores the configuration URL and uses the given one instead.

qi::FutureSync<void> qi::Session::connect(const std::string& serviceDirectoryURL)
qi::FutureSync<void> qi::Session::connect(const qi::Url& serviceDirectoryURL)
bool qi::Session::isConnected() const
qi::Url qi::Session::url() const
qi::FutureSync<std::vector<ServiceInfo>> qi::Session::services(ServiceLocality locality = ServiceLocality_All)
qi::FutureSync<qi::AnyObject> qi::Session::service(const std::string& name)
qi::FutureSync<qi::AnyObject> qi::Session::service(const std::string& name, qi::MilliSeconds timeout)
qi::FutureSync<qi::AnyObject> qi::Session::service(const std::string& name, const std::string& protocol)
qi::FutureSync<qi::AnyObject> qi::Session::service(const std::string& name, const std::string& protocol, qi::MilliSeconds timeout)

Returns the asked service.

If the timeout triggers, the returned future is canceled.

qi::FutureSync<void> qi::Session::listen()

Uses the listen URLs from the configuration.

qi::FutureSync<void> qi::Session::listen(const qi::Url& address)

Ignores the configuration listen URLs and uses the given one instead.

qi::FutureSync<void> qi::Session::listen(const std::vector<qi::Url>& addresses)

Ignores the configuration listen URLs and uses the given ones instead. If the parameter is empty, uses the hardcoded default listen URL.

std::vector<qi::Url> qi::Session::endpoints() const
bool qi::Session::setIdentity(const std::string& key, const std::string& crt)
qi::FutureSync<void> qi::Session::close()
qi::FutureSync<void> qi::Session::listenStandalone()

Uses the listen URLs from the configuration or the hardcoded default listen URL if the first one is empty.

qi::FutureSync<void> qi::Session::listenStandalone(const qi::Url& address)

Ignores the configuration listen URLs and uses the given one instead.

qi::FutureSync<void> qi::Session::listenStandalone(const std::vector<qi::Url>& addresses)

Ignores the configuration listen URLs and uses the given ones instead.

qi::FutureSync<unsigned int> qi::Session::registerService(const std::string& name, AnyObject object)
qi::FutureSync<void> qi::Session::unregisterService(unsigned int serviceId)
void qi::Session::setAuthProviderFactory(AuthProviderFactoryPtr)
void qi::Session::setClientAuthenticatorFactory(ClientAuthenticatorFactoryPtr)
qi::FutureSync<unsigned int> qi::Session::loadService(const std::string& moduleName, const std::string& renameModule = "", const AnyReferenceVector& args = AnyReferenceVector()

Load a module and register the specified object on the session

Tries to call the factory with (this, args...) if possible, otherwise it calls it with (args...) only.

template<typename T>
qi::FutureSync<T> qi::Session::callModule(const std::string& moduleName, const AnyReferenceVector& args = AnyReferenceVector()

Load a module and call the specified function asynchronously

Tries to call the function with (this, args...) if possible, otherwise it calls it with (args...) only.

FutureSync<void> qi::Session::waitForService(const std::string& servicename, MilliSeconds timeout)

Waits for a service to become available and fails if the timeout has expired. The future is set immediately if the service is already available. The future is canceled if the timeout triggered.

qi::FutureSync<void> qi::Session::waitForService(const std::string& service)

Waits for a service to become available. The future is set immediately if the service is already available. The timeout used is given by defaultWaitForServiceTimeout().