CppWAMP
C++11 client library for the WAMP protocol
|
Coroutine API used by a client peer in WAMP applications. More...
#include <cppwamp/coro/corosession.hpp>
Public Types | |
using | Ptr = std::shared_ptr< CoroSession > |
Shared pointer to a CoroSession. | |
using | Base = Session |
The base class type that this mixin extends. | |
using | State = SessionState |
Enumerates the possible states that a CoroSession can be in. | |
using | EventSlot = std::function< void(Event)> |
Function type for handling pub/sub events. | |
using | CallSlot = std::function< Outcome(Invocation)> |
Function type for handling remote procedure calls. | |
using | InterruptSlot = std::function< Outcome(Interruption)> |
Function type for handling RPC interruptions. | |
template<typename TSpawnHandler > | |
using | YieldContext = boost::asio::basic_yield_context< TSpawnHandler > |
Yield context type used by the boost::asio::spawn handler. | |
![]() | |
using | Ptr = std::shared_ptr< Session > |
Shared pointer to a Session. | |
using | State = SessionState |
Enumerates the possible states that a Session can be in. | |
using | EventSlot = AnyReusableHandler< void(Event)> |
Type-erased wrapper around a WAMP event handler. | |
using | CallSlot = AnyReusableHandler< Outcome(Invocation)> |
Type-erased wrapper around an RPC handler. | |
using | InterruptSlot = AnyReusableHandler< Outcome(Interruption)> |
Type-erased wrapper around an RPC interruption handler. | |
using | LogHandler = AnyReusableHandler< void(std::string)> |
Type-erased wrapper around a log event handler. | |
using | StateChangeHandler = AnyReusableHandler< void(SessionState)> |
Type-erased wrapper around a Session state change handler. | |
using | ChallengeHandler = AnyReusableHandler< void(Challenge)> |
Type-erased wrapper around an authentication challenge handler. | |
template<typename T , typename C > | |
using | Deduced = decltype(boost::asio::async_initiate< C, void(T)>(std::declval< GenericOp & >(), std::declval< C & >())) |
Obtains the type returned by boost::asio::async_initiate with given the completion token type C and signature void(T) . More... | |
Public Member Functions | |
Session Management | |
void | connect (AsyncHandler< size_t > handler) |
Asynchronously attempts to connect to a router. More... | |
template<typename H > | |
size_t | connect (YieldContext< H > yield, std::error_code *ec=nullptr) |
Attempts to connect to a router. More... | |
void | join (Realm realm, AsyncHandler< SessionInfo > handler) |
Asynchronously attempts to join the given WAMP realm. More... | |
template<typename H > | |
SessionInfo | join (Realm realm, YieldContext< H > yield, std::error_code *ec=nullptr) |
Attempts to join the given WAMP realm. More... | |
void | authenticate (Authentication auth) |
Sends an AUTHENTICATE in response to a CHALLENGE . More... | |
void | leave (AsyncHandler< Reason > handler) |
Asynchronously leaves the WAMP session. More... | |
template<typename H > | |
Reason | leave (YieldContext< H > yield, std::error_code *ec=nullptr) |
Leaves the WAMP session. More... | |
void | leave (Reason reason, AsyncHandler< Reason > handler) |
Asynchronously leaves the WAMP session with the given reason. More... | |
template<typename H > | |
Reason | leave (Reason reason, YieldContext< H > yield, std::error_code *ec=nullptr) |
Leaves the WAMP session with the given reason. More... | |
Pub/Sub | |
void | subscribe (Topic topic, EventSlot slot, AsyncHandler< Subscription > handler) |
Asynchronously subscribes to WAMP pub/sub events having the given topic. More... | |
template<typename H > | |
Subscription | subscribe (Topic topic, EventSlot slot, YieldContext< H > yield, std::error_code *ec=nullptr) |
Subscribes to WAMP pub/sub events having the given topic. More... | |
void | unsubscribe (const Subscription &sub) |
Unsubscribes a subscription to a topic. More... | |
void | unsubscribe (const Subscription &sub, AsyncHandler< bool > handler) |
Asynchronously unsubscribes a subscription to a topic and waits for router acknowledgement, if necessary. More... | |
template<typename H > | |
bool | unsubscribe (const Subscription &sub, YieldContext< H > yield, std::error_code *ec=nullptr) |
Unsubscribes a subscription to a topic and waits for router acknowledgement if necessary. More... | |
void | publish (Pub pub) |
Publishes an event. More... | |
void | publish (Pub pub, AsyncHandler< PublicationId > handler) |
Asynchronously publishes an event and waits for an acknowledgement from the router. More... | |
template<typename H > | |
PublicationId | publish (Pub pub, YieldContext< H > yield, std::error_code *ec=nullptr) |
Publishes an event and waits for an acknowledgement from the router. More... | |
Remote Procedures | |
void | enroll (Procedure procedure, CallSlot slot, AsyncHandler< Registration > handler) |
Asynchronously registers a WAMP remote procedure call. More... | |
template<typename H > | |
Registration | enroll (Procedure procedure, CallSlot slot, YieldContext< H > yield, std::error_code *ec=nullptr) |
Registers a WAMP remote procedure call. More... | |
void | enroll (Procedure procedure, CallSlot callSlot, InterruptSlot interruptSlot, AsyncHandler< Registration > handler) |
Asynchronously registers a WAMP remote procedure call with an interruption handler. More... | |
template<typename H > | |
Registration | enroll (Procedure procedure, CallSlot slot, InterruptSlot interruptSlot, YieldContext< H > yield, std::error_code *ec=nullptr) |
Registers a WAMP remote procedure call with an interruption handler. More... | |
void | unregister (const Registration ®) |
Unregisters a remote procedure call. More... | |
void | unregister (const Registration ®, AsyncHandler< bool > handler) |
Asynchronously unregisters a remote procedure call and waits for router acknowledgement. More... | |
template<typename H > | |
bool | unregister (const Registration ®, YieldContext< H > yield, std::error_code *ec=nullptr) |
Unregisters a remote procedure call and waits for router acknowledgement. More... | |
RequestId | call (Rpc procedure, AsyncHandler< Result > handler) |
Asynchronously calls a remote procedure. More... | |
template<typename H > | |
Result | call (Rpc rpc, YieldContext< H > yield, std::error_code *ec=nullptr) |
Calls a remote procedure. More... | |
Coroutine | |
template<typename H > | |
void | suspend (YieldContext< H > yield) |
Cooperatively suspend this coroutine to allow others to run. More... | |
Deleted Functions | |
void | reset ()=delete |
The reset function is removed from the coroutine API. More... | |
![]() | |
virtual | ~Session () |
Destructor. More... | |
Session (const Session &)=delete | |
Session & | operator= (const Session &)=delete |
AnyIoExecutor | userExecutor () const |
Obtains the fallback executor used to execute user-provided handlers. | |
AnyIoExecutor | userIosvc () const |
Legacy function kept for backward compatiblity. More... | |
IoStrand | strand () const |
Obtains the execution context in which which I/O operations are serialized. | |
SessionState | state () const |
Returns the current state of the session. | |
void | setWarningHandler (LogHandler handler) |
Sets the log handler that is dispatched for warnings. More... | |
void | setWarningHandler (ThreadSafe, LogHandler handler) |
Thread-safe setting of warning handler. More... | |
void | setTraceHandler (LogHandler handler) |
Sets the log handler that is dispatched for debug traces. More... | |
void | setTraceHandler (ThreadSafe, LogHandler handler) |
Thread-safe setting of trace handler. More... | |
void | setStateChangeHandler (StateChangeHandler handler) |
Sets the handler that is posted for session state changes. More... | |
void | setStateChangeHandler (ThreadSafe, StateChangeHandler handler) |
Thread-safe setting of state change handler. More... | |
void | setChallengeHandler (ChallengeHandler handler) |
Sets the handler that is dispatched for authentication challenges. More... | |
void | setChallengeHandler (ThreadSafe, ChallengeHandler handler) |
Thread-safe setting of state change handler. More... | |
template<typename C > | |
Deduced< ErrorOr< std::size_t >, C > | connect (C &&completion) |
Asynchronously attempts to connect to a router. More... | |
template<typename C > | |
Deduced< ErrorOr< std::size_t >, C > | connect (ThreadSafe, C &&completion) |
Thread-safe connect. More... | |
template<typename C > | |
Deduced< ErrorOr< SessionInfo >, C > | join (Realm realm, C &&completion) |
Asynchronously attempts to join the given WAMP realm. More... | |
template<typename C > | |
Deduced< ErrorOr< SessionInfo >, C > | join (ThreadSafe, Realm realm, C &&completion) |
Thread-safe join. More... | |
void | authenticate (Authentication auth) |
Sends an AUTHENTICATE in response to a CHALLENGE . More... | |
void | authenticate (ThreadSafe, Authentication auth) |
Thread-safe authenticate. More... | |
template<typename C > | |
Deduced< ErrorOr< Reason >, C > | leave (C &&completion) |
Asynchronously leaves the WAMP session. More... | |
template<typename C > | |
Deduced< ErrorOr< Reason >, C > | leave (ThreadSafe, C &&completion) |
Thread-safe leave. More... | |
template<typename C > | |
Deduced< ErrorOr< Reason >, C > | leave (Reason reason, C &&completion) |
Asynchronously leaves the WAMP session with the given reason. More... | |
template<typename C > | |
Deduced< ErrorOr< Reason >, C > | leave (ThreadSafe, Reason reason, C &&completion) |
Thread-safe leave with reason. More... | |
void | disconnect () |
Disconnects the transport between the client and router. More... | |
void | disconnect (ThreadSafe) |
Thread-safe disconnect. More... | |
void | reset () |
Terminates the transport connection between the client and router. More... | |
void | reset (ThreadSafe) |
Thread-safe reset. More... | |
template<typename C > | |
Deduced< ErrorOr< Subscription >, C > | subscribe (Topic topic, EventSlot eventSlot, C &&completion) |
Subscribes to WAMP pub/sub events having the given topic. More... | |
template<typename C > | |
Deduced< ErrorOr< Subscription >, C > | subscribe (ThreadSafe, Topic topic, EventSlot eventSlot, C &&completion) |
Thread-safe subscribe. More... | |
void | unsubscribe (Subscription sub) |
Unsubscribes a subscription to a topic. More... | |
void | unsubscribe (ThreadSafe, Subscription sub) |
Thread-safe unsubscribe. More... | |
template<typename C > | |
Deduced< ErrorOr< bool >, C > | unsubscribe (Subscription sub, C &&completion) |
Unsubscribes a subscription to a topic and waits for router acknowledgement, if necessary. More... | |
template<typename C > | |
Deduced< ErrorOr< bool >, C > | unsubscribe (ThreadSafe, Subscription sub, C &&completion) |
Thread-safe acknowledged unsubscribe. More... | |
void | publish (Pub pub) |
Publishes an event. More... | |
void | publish (ThreadSafe, Pub pub) |
Thread-safe publish. More... | |
template<typename C > | |
Deduced< ErrorOr< PublicationId >, C > | publish (Pub pub, C &&completion) |
Publishes an event and waits for an acknowledgement from the router. More... | |
template<typename C > | |
Deduced< ErrorOr< PublicationId >, C > | publish (ThreadSafe, Pub pub, C &&completion) |
Thread-safe acknowledged publish. More... | |
template<typename C > | |
Deduced< ErrorOr< Registration >, C > | enroll (Procedure procedure, CallSlot callSlot, C &&completion) |
Registers a WAMP remote procedure call. More... | |
template<typename C > | |
Deduced< ErrorOr< Registration >, C > | enroll (ThreadSafe, Procedure procedure, CallSlot callSlot, C &&completion) |
Thread-safe enroll. More... | |
template<typename C > | |
Deduced< ErrorOr< Registration >, C > | enroll (Procedure procedure, CallSlot callSlot, InterruptSlot interruptSlot, C &&completion) |
Registers a WAMP remote procedure call with an interruption handler. More... | |
template<typename C > | |
Deduced< ErrorOr< Registration >, C > | enroll (ThreadSafe, Procedure procedure, CallSlot callSlot, InterruptSlot interruptSlot, C &&completion) |
Thread-safe enroll interruptible. More... | |
void | unregister (Registration reg) |
Unregisters a remote procedure call. More... | |
void | unregister (ThreadSafe, Registration reg) |
Thread-safe unregister. More... | |
template<typename C > | |
Deduced< ErrorOr< bool >, C > | unregister (Registration reg, C &&completion) |
Unregisters a remote procedure call and waits for router acknowledgement. More... | |
template<typename C > | |
Deduced< ErrorOr< bool >, C > | unregister (ThreadSafe, Registration reg, C &&completion) |
Thread-safe acknowledged unregister. More... | |
template<typename C > | |
Deduced< ErrorOr< Result >, C > | call (Rpc rpc, C &&completion) |
Calls a remote procedure. More... | |
template<typename C > | |
Deduced< ErrorOr< Result >, C > | call (ThreadSafe, Rpc rpc, C &&completion) |
Thread-safe call. More... | |
template<typename C > | |
Deduced< ErrorOr< Result >, C > | call (Rpc rpc, CallChit &chit, C &&completion) |
Calls a remote procedure, obtaining a token that can be used for cancellation. More... | |
template<typename C > | |
Deduced< ErrorOr< Result >, C > | call (ThreadSafe, Rpc rpc, CallChit &chit, C &&completion) |
Thread-safe call with CallChit capture. More... | |
void | cancel (CallChit) |
Cancels a remote procedure using the cancel mode that was specified in the Rpc. More... | |
void | cancel (ThreadSafe, CallChit) |
Thread-safe cancel. More... | |
void | cancel (CallChit, CallCancelMode mode) |
Cancels a remote procedure using the given mode. More... | |
void | cancel (ThreadSafe, CallChit, CallCancelMode mode) |
Thread-safe cancel with a given mode. More... | |
void | cancel (CallCancellation cancellation) |
Cancels a remote procedure. More... | |
void | cancel (ThreadSafe, CallCancellation cancellation) |
Thread-safe cancel. More... | |
Static Public Member Functions | |
static Ptr | create (AnyIoExecutor exec, const Connector::Ptr &connector) |
Creates a new CoroSession instance. More... | |
static Ptr | create (AnyIoExecutor exec, const ConnectorList &connectors) |
Creates a new CoroSession instance. More... | |
template<typename TExecutionContext > | |
static Ptr | create (TExecutionContext &context, const Connector::Ptr &connector) |
Creates a new CoroSession instance. More... | |
template<typename TExecutionContext > | |
static Ptr | create (TExecutionContext &context, const ConnectorList &connectors) |
Creates a new CoroSession instance. More... | |
![]() | |
static Ptr | create (AnyIoExecutor exec, const Connector::Ptr &connector) |
Creates a new Session instance. More... | |
static Ptr | create (AnyIoExecutor exec, const ConnectorList &connectors) |
Creates a new Session instance. More... | |
template<typename TExecutionContext > | |
static Ptr | create (TExecutionContext &context, const Connector::Ptr &connector) |
Creates a new Session instance. More... | |
template<typename TExecutionContext > | |
static Ptr | create (TExecutionContext &context, const ConnectorList &connectors) |
Creates a new Session instance. More... | |
static const Object & | roles () |
Obtains a dictionary of roles and features supported on the client side. More... | |
Coroutine API used by a client peer in WAMP applications.
This class differs from Session as follows:
std::error_code
can be passed to coroutine operations. If a runtime error occurs, it will set the pointed-to error code instead of throwing an error::Failure exception.TBase | Ignored |
|
static |
Creates a new CoroSession instance.
The provided executor serves as a fallback when asynchronous operation handlers don't bind a specific executor (in lieu of using the system executor as fallback.
session->state() == SessionState::disconnected
exec | Executor with which to post all user-provided handlers. |
connector | Connection details for the transport to use. |
|
static |
Creates a new CoroSession instance.
The provided executor serves as a fallback when asynchronous operation handlers don't bind a specific executor (in lieu of using the system executor as fallback.
connectors.empty() == false
session->state() == SessionState::disconnected
error::Logic | if connectors.empty() == true |
exec | Executor with which to post all user-provided handlers. |
connectors | A list of connection details for the transports to use. |
|
inlinestatic |
Creates a new CoroSession instance.
The provided executor serves as a fallback when asynchronous operation handlers don't bind a specific executor (in lieu of using the system executor as fallback.
session->state() == SessionState::disconnected
Only participates in overload resolution when isExecutionContext<TExecutionContext>() == true
TExecutionContext | Must meet the requirements of Boost.Asio's ExecutionContext |
context | Provides executor with which to post all user-provided handlers. |
connector | Connection details for the transport to use. |
|
inlinestatic |
Creates a new CoroSession instance.
The provided executor serves as a fallback when asynchronous operation handlers don't bind a specific executor (in lieu of using the system executor as fallback.
session->state() == SessionState::disconnected
Only participates in overload resolution when isExecutionContext<TExecutionContext>() == true
TExecutionContext | Must meet the requirements of Boost.Asio's ExecutionContext |
context | Provides executor with which to post all user-provided handlers. |
connectors | Connection details for the transport to use. |
void wamp::CoroSession< B >::connect | ( | AsyncHandler< size_t > | handler | ) |
Asynchronously attempts to connect to a router.
The session will attempt to connect using the transports that were specified by the wamp::Connector objects passed during create(). If more than one transport was specified, they will be traversed in the same order as they appeared in the ConnectorList.
this->state() == SessionState::disconnected
this->state() == SessionState::connecting
std::error_code
if only one transport was specified and it failed to connect. error::Logic | if this->state() != SessionState::disconnected |
handler | Handler to invoke when the operation completes. |
size_t wamp::CoroSession< B >::connect | ( | YieldContext< H > | yield, |
std::error_code * | ec = nullptr |
||
) |
Attempts to connect to a router.
The session will attempt to connect using the transports that were specified by the wamp::Connector objects passed during create(). If more than one transport was specified, they will be traversed in the same order as they appeared in the ConnectorList.
this->state() == SessionState::disconnected
this->state() == SessionState::connecting
std::error_code
if only one transport was specified and it failed to connect. error::Logic | if this->state() != SessionState::disconnected |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::join | ( | Realm | realm, |
AsyncHandler< SessionInfo > | handler | ||
) |
Asynchronously attempts to join the given WAMP realm.
this->state() == SessionState::connected
this->state() == SessionState::establishing
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::connected |
realm | Details on the realm to join. |
handler | Handler to invoke when the operation completes. |
SessionInfo wamp::CoroSession< B >::join | ( | Realm | realm, |
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Attempts to join the given WAMP realm.
this->state() == SessionState::connected
this->state() == SessionState::establishing
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::connected |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
realm | Details on the realm to join. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::authenticate | ( | Authentication | auth | ) |
Sends an AUTHENTICATE
in response to a CHALLENGE
.
this->state() == SessionState::authenticating
error::Logic | if this->state() != SessionState::authenticating |
void wamp::CoroSession< B >::leave | ( | AsyncHandler< Reason > | handler | ) |
Asynchronously leaves the WAMP session.
The "wamp.close.close_realm" reason is sent as part of the outgoing GOODBYE
message.
GOODBYE
response returned by the router. this->state() == SessionState::established
this->state() == SessionState::shuttingDown
GOODBYE
response was received.std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
handler | Handler to invoke when the operation completes. |
Reason wamp::CoroSession< B >::leave | ( | YieldContext< H > | yield, |
std::error_code * | ec = nullptr |
||
) |
Leaves the WAMP session.
The "wamp.close.close_realm" reason is sent as part of the outgoing GOODBYE
message.
GOODBYE
response returned by the router. this->state() == SessionState::established
this->state() == SessionState::shuttingDown
GOODBYE
response was received.std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::leave | ( | Reason | reason, |
AsyncHandler< Reason > | handler | ||
) |
Asynchronously leaves the WAMP session with the given reason.
GOODBYE
response returned by the router. this->state() == SessionState::established
this->state() == SessionState::shuttingDown
GOODBYE
response was received.std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
reason | Reason URI and other options |
handler | Handler to invoke when the operation completes. |
Reason wamp::CoroSession< B >::leave | ( | Reason | reason, |
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Leaves the WAMP session with the given reason.
GOODBYE
response returned by the router. this->state() == SessionState::established
this->state() == SessionState::shuttingDown
GOODBYE
response was received.std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
reason | _Reason_ URI and other details to send to the router. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::subscribe | ( | Topic | topic, |
EventSlot | slot, | ||
AsyncHandler< Subscription > | handler | ||
) |
Asynchronously subscribes to WAMP pub/sub events having the given topic.
this->state() == SessionState::established
ERROR
response.std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
topic | The topic to subscribe to. |
slot | The callable target to invoke when a matching event is received. |
handler | Handler to invoke when the subscribe operation completes. |
Subscription wamp::CoroSession< B >::subscribe | ( | Topic | topic, |
EventSlot | slot, | ||
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Subscribes to WAMP pub/sub events having the given topic.
this->state() == SessionState::established
ERROR
response.std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
topic | Details on the topic to subscribe to. |
slot | The callable target to invoke when a matching event is received. |
yield | Represents the current coroutine. |
ec | Pointer to an optional error code to set instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::unsubscribe | ( | const Subscription & | sub | ) |
Unsubscribes a subscription to a topic.
This function can be safely called during any session state. If the subscription is no longer applicable, then the unsubscribe operation will effectively do nothing.
!!sub == true
error::Logic | if the given subscription is empty |
sub | The subscription to unsubscribe from. |
void wamp::CoroSession< B >::unsubscribe | ( | const Subscription & | sub, |
AsyncHandler< bool > | handler | ||
) |
Asynchronously unsubscribes a subscription to a topic and waits for router acknowledgement, if necessary.
If there are other local subscriptions on this session remaining for the same topic, then the session does not send an UNSUBSCRIBE
message to the router.
false
if the subscription was already removed, true
otherwise. !!sub == true
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if the given subscription is empty |
error::Logic | if this->state() != SessionState::established |
sub | The subscription to unsubscribe from. |
handler | Handler to invoke when the operation completes. |
bool wamp::CoroSession< B >::unsubscribe | ( | const Subscription & | sub, |
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Unsubscribes a subscription to a topic and waits for router acknowledgement if necessary.
If there are other local subscriptions on this session remaining for the same topic, then the session does not send an UNSUBSCRIBE
message to the router.
false
if the subscription was already removed, true
otherwise. !!sub == true
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if the given subscription is empty |
error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
sub | The subscription to unsubscribe from. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::publish | ( | Pub | pub | ) |
Publishes an event.
this->state() == SessionState::established
error::Logic | if this->state() != SessionState::established |
pub | The publication to publish. |
void wamp::CoroSession< B >::publish | ( | Pub | pub, |
AsyncHandler< PublicationId > | handler | ||
) |
Asynchronously publishes an event and waits for an acknowledgement from the router.
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
pub | The publication to publish. |
handler | Handler to invoke when the operation completes. |
PublicationId wamp::CoroSession< B >::publish | ( | Pub | pub, |
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Publishes an event and waits for an acknowledgement from the router.
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null |
pub | The publication to publish |
yield | Represents the current coroutine. |
ec | Optional error code to set, instead of throwing an exception. |
void wamp::CoroSession< B >::enroll | ( | Procedure | procedure, |
CallSlot | slot, | ||
AsyncHandler< Registration > | handler | ||
) |
Asynchronously registers a WAMP remote procedure call.
enroll
because register
is a reserved C++ keyword. this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
procedure | The procedure to register. |
slot | The handler to execute when the RPC is invoked. |
handler | Handler to invoke when the enroll operation completes. |
Registration wamp::CoroSession< B >::enroll | ( | Procedure | procedure, |
CallSlot | slot, | ||
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Registers a WAMP remote procedure call.
enroll
because register
is a reserved C++ keyword. this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
procedure | The procedure URI to register. |
slot | Callable target to invoke when a matching RPC invocation is received. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::enroll | ( | Procedure | procedure, |
CallSlot | callSlot, | ||
InterruptSlot | interruptSlot, | ||
AsyncHandler< Registration > | handler | ||
) |
Asynchronously registers a WAMP remote procedure call with an interruption handler.
enroll
because register
is a reserved C++ keyword. this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
procedure | The procedure to register. |
callSlot | The handler to execute when the RPC is invoked. |
interruptSlot | Handler to execute when RPC is interrupted. |
handler | Handler to invoke when the enroll operation completes. |
Registration wamp::CoroSession< B >::enroll | ( | Procedure | procedure, |
CallSlot | callSlot, | ||
InterruptSlot | interruptSlot, | ||
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Registers a WAMP remote procedure call with an interruption handler.
enroll
because register
is a reserved C++ keyword. this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
procedure | The procedure URI to register. |
callSlot | Callable target to invoke when a matching RPC invocation is received. |
interruptSlot | Handler to execute when RPC is interrupted. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
void wamp::CoroSession< B >::unregister | ( | const Registration & | reg | ) |
Unregisters a remote procedure call.
This function can be safely called during any session state. If the registration is no longer applicable, then the unregister operation will effectively do nothing.
!!reg == true
error::Logic | if the given registration is empty |
reg | The RPC registration to unregister. |
void wamp::CoroSession< B >::unregister | ( | const Registration & | reg, |
AsyncHandler< bool > | handler | ||
) |
Asynchronously unregisters a remote procedure call and waits for router acknowledgement.
false
if the registration was already removed, true
otherwise. !!reg == true
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if the given registration is empty |
error::Logic | if this->state() != SessionState::established |
reg | The RPC registration to unregister. |
handler | Handler to invoke when the operation completes. |
bool wamp::CoroSession< B >::unregister | ( | const Registration & | reg, |
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Unregisters a remote procedure call and waits for router acknowledgement.
false
if the registration was already removed, true
otherwise. !!reg == true
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if the given registration is empty |
error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
reg | The RPC registration to unregister. |
yield | Represents the current coroutine. |
ec | Optional pointer to an error code to set, instead of throwing an exception upon failure. |
RequestId wamp::CoroSession< B >::call | ( | Rpc | rpc, |
AsyncHandler< Result > | handler | ||
) |
Asynchronously calls a remote procedure.
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
rpc | Details about the RPC. |
handler | Handler to invoke when the operation completes. |
Result wamp::CoroSession< B >::call | ( | Rpc | rpc, |
YieldContext< H > | yield, | ||
std::error_code * | ec = nullptr |
||
) |
Calls a remote procedure.
this->state() == SessionState::established
std::error_code
for protocol and transport errors. error::Logic | if this->state() != SessionState::established |
error::Failure | with an error code if a runtime error occured and the ec parameter is null. |
rpc | Details on the RPC to call. |
yield | Represents the current coroutine. |
ec | Optional error code to set, instead of throwing an exception. |
void wamp::CoroSession< B >::suspend | ( | YieldContext< H > | yield | ) |
Cooperatively suspend this coroutine to allow others to run.
Has the same effect as
|
delete |
The reset function is removed from the coroutine API.
It is removed because its behavior in Session is to abort all pending operations without invoking their associated asynchronous completion handlers. Implementing this same behavior in CoroSession could result in hung coroutines (because the pending CoroSession operations might never return).