autobahn::wamp_session Class Reference

Representation of a WAMP session. More...

#include <wamp_session.hpp>

Inheritance diagram for autobahn::wamp_session:
autobahn::wamp_transport_handler

Public Member Functions

 wamp_session (boost::asio::io_service &io_service, bool debug_enabled=false)
 Create a new WAMP session. More...
 
boost::future< void > start ()
 Establishes a session with the router. More...
 
boost::future< void > stop ()
 Stops the session with the router. More...
 
boost::future< uint64_t > join (const std::string &realm, const std::vector< std::string > &authmethods=std::vector< std::string >(), const std::string &authid="")
 Join a realm with the session. More...
 
boost::future< std::string > leave (const std::string &reason=std::string("wamp.error.close_realm"))
 Leave the realm. More...
 
boost::future< void > publish (const std::string &topic, const wamp_publish_options &options=wamp_publish_options())
 Publish an event with empty payload to a topic. More...
 
template<typename List >
boost::future< void > publish (const std::string &topic, const List &arguments, const wamp_publish_options &options=wamp_publish_options())
 Publish an event with positional payload to a topic. More...
 
template<typename List , typename Map >
boost::future< void > publish (const std::string &topic, const List &arguments, const Map &kw_arguments, const wamp_publish_options &options=wamp_publish_options())
 Publish an event with both positional and keyword payload to a topic. More...
 
boost::future< wamp_subscriptionsubscribe (const std::string &topic, const wamp_event_handler &handler, const wamp_subscribe_options &options=wamp_subscribe_options())
 Subscribe a handler to a topic to receive events. More...
 
boost::future< void > unsubscribe (const wamp_subscription &subscription)
 Unubscribe a handler to previously subscribed topic. More...
 
boost::future< wamp_call_resultcall (const std::string &procedure, const wamp_call_options &options=wamp_call_options())
 Calls a remote procedure with no arguments. More...
 
template<typename List >
boost::future< wamp_call_resultcall (const std::string &procedure, const List &arguments, const wamp_call_options &options=wamp_call_options())
 Calls a remote procedure with positional arguments. More...
 
template<typename List , typename Map >
boost::future< wamp_call_resultcall (const std::string &procedure, const List &arguments, const Map &kw_arguments, const wamp_call_options &options=wamp_call_options())
 Calls a remote procedure with positional and keyword arguments. More...
 
boost::future< wamp_registrationprovide (const std::string &uri, const wamp_procedure &procedure, const provide_options &options=provide_options())
 Register a procedure that can be called remotely. More...
 
boost::future< void > unprovide (const wamp_registration &registration)
 Unregister a handler to previosly registered service. More...
 
virtual boost::future< wamp_authenticateon_challenge (const wamp_challenge &challenge)
 Function called by the session when authenticating. More...
 
const std::unordered_map< std::string, msgpack::object > & welcome_details ()
 Accessor method to WELCOME DETAILS dictionary containing router roles and corresponding features, authid, authrole, ...) More...
 
- Public Member Functions inherited from autobahn::wamp_transport_handler
virtual ~wamp_transport_handler ()=default
 Default virtual destructor.
 

Detailed Description

Representation of a WAMP session.

Definition at line 88 of file wamp_session.hpp.

Constructor & Destructor Documentation

autobahn::wamp_session::wamp_session ( boost::asio::io_service &  io_service,
bool  debug_enabled = false 
)

Create a new WAMP session.

Parameters
io_serviceThe io service to drive event dispatching.
debug_enabledWhether or not to run in debug mode.

Member Function Documentation

boost::future<wamp_call_result> autobahn::wamp_session::call ( const std::string &  procedure,
const wamp_call_options options = wamp_call_options() 
)

Calls a remote procedure with no arguments.

Parameters
procedureThe URI of the remote procedure to call.
optionsThe options to pass in the call to the router.
Returns
A future that resolves to the result of the remote procedure call.
template<typename List >
boost::future<wamp_call_result> autobahn::wamp_session::call ( const std::string &  procedure,
const List &  arguments,
const wamp_call_options options = wamp_call_options() 
)

Calls a remote procedure with positional arguments.

Parameters
procedureThe URI of the remote procedure to call.
argumentsThe positional arguments for the call.
optionsThe options to pass in the call to the router.
Returns
A future that resolves to the result of the remote procedure call.
template<typename List , typename Map >
boost::future<wamp_call_result> autobahn::wamp_session::call ( const std::string &  procedure,
const List &  arguments,
const Map &  kw_arguments,
const wamp_call_options options = wamp_call_options() 
)

Calls a remote procedure with positional and keyword arguments.

Parameters
procedureThe URI of the remote procedure to call.
argumentsThe positional arguments for the call.
kw_argumentsThe keyword arguments for the call.
optionsThe options to pass in the call to the router.
Returns
A future that resolves to the result of the remote procedure call.
boost::future<uint64_t> autobahn::wamp_session::join ( const std::string &  realm,
const std::vector< std::string > &  authmethods = std::vector< std::string >(),
const std::string &  authid = "" 
)

Join a realm with the session.

Parameters
realmThe realm to join on the application router.
authmethodsThe authentication methods this instance support e.g. "wampcra","ticket"
authidThe username or maybe an other identifier for the user to join.
Returns
A future that resolves with the session ID when the realm was joined.
boost::future<std::string> autobahn::wamp_session::leave ( const std::string &  reason = std::string("wamp.error.close_realm"))

Leave the realm.

Parameters
reasonAn optional WAMP URI providing a reason for leaving.
Returns
A future that resolves with the reason sent by the peer.
virtual boost::future<wamp_authenticate> autobahn::wamp_session::on_challenge ( const wamp_challenge challenge)
virtual

Function called by the session when authenticating.

It always has to be re-implemented (if authentication is part of the system).

Parameters
challengeThe challenge from the router containing enough information for the system to prove membership.
Returns
A future that resolves to an authentication response.
boost::future<wamp_registration> autobahn::wamp_session::provide ( const std::string &  uri,
const wamp_procedure &  procedure,
const provide_options &  options = provide_options() 
)

Register a procedure that can be called remotely.

Parameters
uriThe URI associated with the procedure.
procedureThe procedure to be exposed as a remotely callable procedure.
optionsOptions for registering the procedure.
Returns
A future that resolves to a autobahn::registration
boost::future<void> autobahn::wamp_session::start ( )

Establishes a session with the router.

Returns
A future that indicates if the session was successfully started.
boost::future<void> autobahn::wamp_session::stop ( )

Stops the session with the router.

Returns
A future that indicates if the session was successfully stopped.
boost::future<wamp_subscription> autobahn::wamp_session::subscribe ( const std::string &  topic,
const wamp_event_handler &  handler,
const wamp_subscribe_options options = wamp_subscribe_options() 
)

Subscribe a handler to a topic to receive events.

Parameters
topicThe URI of the topic to subscribe to.
handlerThe handler that will receive events under the subscription.
optionsThe options to pass in the subscribe request to the router.
Returns
A future that resolves to the autobahn::subscription.
boost::future<void> autobahn::wamp_session::unprovide ( const wamp_registration registration)

Unregister a handler to previosly registered service.

Parameters
registrationThe registration to unregister.
Returns
A future that resolves to the unregistered response.
boost::future<void> autobahn::wamp_session::unsubscribe ( const wamp_subscription subscription)

Unubscribe a handler to previously subscribed topic.

Parameters
subscriptionThe subscription to unsubscribe from.
Returns
A future that resolves to the unsubscribed response.
const std::unordered_map<std::string, msgpack::object>& autobahn::wamp_session::welcome_details ( )

Accessor method to WELCOME DETAILS dictionary containing router roles and corresponding features, authid, authrole, ...)

Returns
A dictionary of objects received with WELCOME message upon joining. i.e. { "realm": "<string>", "authprovider": "dynamic", "roles": { "broker": { "features": { "publisher_identification": true, "pattern_based_subscription": true, ... } }, "dealer": { "features": { "pattern_based_registration": true, "progressive_call_results": true, ... } } }, "authid": "<assigned authid>", "authrole": "<assigned auth role>", "authmethod": "wampcra", ... }