7 #ifndef _QI_MESSAGING_SESSION_HPP_
8 #define _QI_MESSAGING_SESSION_HPP_
17 #include <boost/shared_ptr.hpp>
22 # pragma warning( push )
23 # pragma warning( disable: 4251 )
39 static Url defaultConnectUrl();
40 static Url defaultListenUrl();
44 KA_GENERATE_FRIEND_REGULAR_OPS_2(
SessionConfig, connectUrl, listenUrls)
47 boost::optional<
Url> connectUrl;
48 std::vector<
Url> listenUrls;
58 Session(
bool enforceAuthentication =
false,
SessionConfig config = {});
64 ServiceLocality_All = 0,
65 ServiceLocality_Local = 1,
66 ServiceLocality_Remote = 2
69 static const char* serviceDirectoryServiceName();
83 bool isConnected()
const;
95 return service(name,
"", defaultServiceTimeout());
100 return service(name,
"", timeout);
104 const std::string& protocol)
106 return service(name, protocol, defaultServiceTimeout());
113 const std::string& protocol,
127 std::vector<qi::Url> endpoints()
const;
128 bool setIdentity(
const std::string& key,
const std::string& crt);
164 template <
typename T>
170 future.
then(
qi::bind(qi::detail::futureAdapterVal<T>, future, promise));
174 #define pushi(z, n, _) params.push_back(p ## n);
175 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
177 const std::string& moduleName, const std::string& renameModule, \
178 qi::AutoAnyReference pp0 comma \
179 QI_GEN_ARGSDECLSAMETYPE(n, qi::AutoAnyReference)) \
181 std::vector<qi::AnyReference> params; \
182 params.reserve(n+1); \
183 params.push_back(pp0); \
184 BOOST_PP_REPEAT(n, pushi, _) \
185 loadService(moduleName, renameModule, params); \
187 template <typename T> \
188 qi::FutureSync<T> callModule( \
189 const std::string& moduleName, \
190 qi::AutoAnyReference pp0 comma \
191 QI_GEN_ARGSDECLSAMETYPE(n, qi::AutoAnyReference)) \
193 std::vector<qi::AnyReference> params; \
194 params.reserve(n+1); \
195 params.push_back(pp0); \
196 BOOST_PP_REPEAT(n, pushi, _) \
197 return callModule<T>(moduleName, params); \
207 FutureSync<void> waitForService(
const std::string& servicename,
MilliSeconds timeout);
229 friend class SessionPrivate;
230 std::unique_ptr<SessionPrivate>
_p;
240 template <
typename... Args>
243 return boost::make_shared<qi::Session>(std::forward<Args>(args)...);
250 # pragma warning( pop )
253 #endif // _QIMESSAGING_SESSION_HPP_
boost::shared_ptr< Session > SessionPtr
qi::FutureSync< qi::AnyObject > service(const std::string &name)
qi::FutureSync< T > callModule(const std::string &moduleName, const AnyReferenceVector &args=AnyReferenceVector())
static qi::MilliSeconds defaultServiceTimeout()
qi::Signal< unsigned int, std::string > serviceRegistered
DurationType< int64_t, boost::ratio< 60 >> Minutes
dll import/export and compiler message
qi::Signal< unsigned int, std::string > serviceUnregistered
auto then(FutureCallbackType type, F &&func) -> Future< typename std::result_of< F(Future< T >)>::type >
Execute a callback when the future is finished.
boost::shared_ptr< AuthProviderFactory > AuthProviderFactoryPtr
boost::shared_ptr< ClientAuthenticatorFactory > ClientAuthenticatorFactoryPtr
std::unique_ptr< SessionPrivate > _p
Future< T > future() const
Get a future linked to this promise. Can be called multiple times.
SessionPtr makeSession(Args &&...args)
qi::FutureSync< qi::AnyObject > service(const std::string &name, qi::MilliSeconds timeout)
DurationType< int64_t, boost::milli > MilliSeconds
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
std::vector< AnyReference > AnyReferenceVector
QI_TYPE_ENUM(qi::Session::ServiceLocality)
boost::shared_ptr< AuthProvider > AuthProviderPtr
std::map< std::string, AnyValue > CapabilityMap
qi::FutureSync< qi::AnyObject > service(const std::string &name, const std::string &protocol)
static MilliSeconds defaultWaitForServiceTimeout()
void setOnCancel(boost::function< void(qi::Promise< T > &)> cancelCallback)
qi::Signal< std::string > disconnected
Force an asynchronous call in an other thread.
std::enable_if< std::is_function< RF >::value, boost::function< RF > >::type bind(AF &&fun, Arg0 &&arg0, Args &&...args)